Commit Graph

11339 Commits

Author SHA1 Message Date
Erik M. Bray 8a32c24a7b Use allocation granularity as the 'page_size' in /proc/<pid>/status as well, for consistency with /proc/<pid>/statm 2016-11-16 15:58:15 +01:00
Erik M. Bray 6477a48cd1 statm should report memory as multiples of allocation_granularity instead of page_size
that ensures that values in statm mupltiplied by POSIX _SC_PAGESIZE give the correct values
2016-11-16 15:58:08 +01:00
Corinna Vinschen 11b7f94212 Fix ShellExecuteW comment
ShellExecuteW long path behaviour is now stable: It doesn't work since
Windows 8.1.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-24 11:23:55 +02:00
Corinna Vinschen bb7ad4ed64 pldd: Fix resource leak and missing check if fopen failed
Fixes Coverity CID 66903

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 17:22:34 +02:00
Corinna Vinschen 79edb254ac passwd: Fix potential buffer overflow
Fixes Coverity CID 66956

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 17:16:30 +02:00
Corinna Vinschen 526107a753 mkgroup/mkpasswd: Fix potential buffer overwrite in corner case
Fixes Coverity CIDs 60076, 60077 and 60081

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 17:04:55 +02:00
Corinna Vinschen 7d5af6f0ba getfacl: Don't trust length of incoming user/groupname
Fixes Coverity CIDs 60079 and 60080

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 16:52:28 +02:00
Corinna Vinschen cf01b8f029 tzset: Fix array length given to GetGeoInfoW
Fixes Coverity CID 66916

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 16:45:21 +02:00
Corinna Vinschen 5e087a8373 strace: Fix Coverity issues
CID 66964: Don't trust environment variable without length check
CID 66968: Add missing va_end

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 16:38:48 +02:00
Corinna Vinschen 9807a501b1 cygcheck: Use snprintf instead of multiple strcat
This not only simplifies the code but also fixes potential
memory corruption

Fixes Coverity CID 66952

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 16:16:22 +02:00
Corinna Vinschen f16f20ff95 cygcheck: Eenable output of Vista++ FS flags
Also, code cleanup

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-23 15:57:40 +02:00
Corinna Vinschen 015f6894a0 cygcheck: Eliminate dead code
Fixes Coverity CID 66907

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:57:03 +02:00
Corinna Vinschen bbeef8ef3f cygcheck: Fix broken test for invalid wcstombs conversion reading symlinks
Fixes Coverity CID 66905

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:53:29 +02:00
Corinna Vinschen 7909b528e5 cygcheck: Fix check for Cygwin symlink
Fixes Coverity CID 66904 and 66906

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:50:33 +02:00
Corinna Vinschen 61401f24ef strace: Add comment trying to explain confusing code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:39:31 +02:00
Corinna Vinschen 46c472a1c1 cygcheck: Close with pclose what has been opened with popen
Fixes Coverity CID 66900

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 22:14:34 +02:00
Corinna Vinschen db8bda4b47 Remove unreachable code from passwd(1)
Fixed Coverity CID 66966

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-22 21:20:28 +02:00
Ken Brown dda82d1a7b Add _PC_CASE_INSENSITIVE to [f]pathconf
Update the getconf utility to support the new flag as well as
_PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY.  These were previously
unsupported, probably as an oversight.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-21 13:39:02 +02:00
Jon Turney 93374181cb Fix SetThreadName with gdb 7.10 on x86
Additionally to eccefd97, we need to ensure the exception handler is
installed for the _ljfault used to implement _try/_except to get called.

Also use the correct macro for x86 conditional compilation.

Addresses https://cygwin.com/ml/cygwin/2016-09/msg00143.html

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-10-20 13:12:20 +01:00
Jon Turney afcde26618 Update FAQ answer about setting an early breakpoint
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-10-20 13:12:20 +01:00
Corinna Vinschen e3ccb68610 Don't check directories always case-insensitive in rename(2)
Long-standing problem in one of the corner cases of rename(2):
If we rename a directory a check is performed to see if newpath is
identical to oldpath or a subdir of oldpath. This check is
(accidentally? no hints anywhere in ChangeLogs or code) performed
case-insensitive for as long as we use Unicode paths and NT functions.
This leads to the problems described in
https://cygwin.com/ml/cygwin/2016-09/msg00264.html

Change this to be conditional case-sensitive as all other checks but
let's take this with a grain of salt.  There may be corner-cases in
this corner-case which require to chek parts of the path always
case-insensitive.  Off the top of my head I can't construct such a
case but that's no proof they don't exist :}

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 13:26:03 +02:00
Corinna Vinschen e1824aea27 Add release msg for 5a3496c
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 12:53:58 +02:00
Corinna Vinschen 5a3496c3e3 Fix regression in console charset handling
Commit d16a5630 dropped usage of cygheap's locale functions
	in favor of local on-the-fly usage of UTF-8 instead of ASCII.
	This allowed to use the current local rather than a fixed
	system-wide locale set at startup time.  d16a5630 just missed
	to add the ASCII->UTF-8 conversion in the console as well.

	Fixes https://cygwin.com/ml/cygwin/2016-10/msg00000.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 12:52:14 +02:00
Corinna Vinschen ba2851eeca Bump Cygwin version to 2.6.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 12:52:14 +02:00
Michael Haubenwallner f763e2dc88 dlopen: on x/lib search x/bin if exe is in x/bin
On 09/02/2016 11:03 AM, Corinna Vinschen wrote:
> On Sep  2 10:46, Michael Haubenwallner wrote:
>> On 09/01/2016 03:32 PM, Corinna Vinschen wrote:
>>> You could just use the global variable program_invocation_name.  If in
>>> doubt, use the Windows path global_progname and convert it to full POSIX
>>> via cygwin_conv_path.
>>
>> Patch updated, using global_progname now.
>
> Looks good and you're right to do it this way since I just noticed
> that program_invocation_name may return a relative pathname.

Yep.

> Btw., in other calls which require the full POSIX path we use
> mount_table->conv_to_posix_path instead of cygwin_conv_path (see
> e. g. fillout_pinfo()).  It's a bit faster.  Maybe something for a
> followup patch.

No problem - attached.
This renders the original patch 4/4 valid again.

> Note for some later improvement:  I really wonder why we don't store
> the absolute POSIX path of the current executable globally yet...

Same here.

Thanks!
/haubi/

>From f7255edd33cb4abe34f27188aab8dccdfa5dd2a0 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Date: Wed, 31 Aug 2016 18:05:11 +0200
Subject: [PATCH 3/4] dlopen: on x/lib search x/bin if exe is in x/bin

citing https://cygwin.com/ml/cygwin-developers/2016-08/msg00020.html
> Consider the file /usr/bin/cygz.dll:
> - dlopen (libz.so)            success
> - dlopen (/usr/bin/libz.so)   success
> - dlopen (/usr/lib/libz.so)   fails

* dlfcn.c (dlopen): For dlopen("x/lib/N"), when the application
executable is in "x/bin/", search for "x/bin/N" before "x/lib/N".
2016-09-08 13:36:32 +02:00
Michael Haubenwallner b37c3ed5e5 dlopen (pathfinder): try each basename per dir
Rather than searching all search dirs per one basename,
search for all basenames within per one search dir.

pathfinder.h (check_path_access): Interchange dir- and basename-loops.
2016-09-08 13:36:31 +02:00
Michael Haubenwallner 97974e3076 dlopen: switch to new pathfinder class
Instead of find_exec, without changing behaviour use new pathfinder
class with new allocator_interface around tmp_pathbuf and new vstrlist
class.
* pathfinder.h (pathfinder): New file.
* vstrlist.h (allocator_interface, allocated_type, vstrlist): New file.
* dlfcn.cc (dlopen): Avoid redundant GetModuleHandleExW with RTLD_NOLOAD
and RTLD_NODELETE.  Switch to new pathfinder class, using
(tmp_pathbuf_allocator): New class.
(get_full_path_of_dll): Drop.
2016-09-08 13:36:29 +02:00
Corinna Vinschen a157df3165 strace: Don't print exception info for SetThreadName exception
The new functionality to set the thread name for debugging purposes
creates exception debugging events.  These are printed out when running
strace.  Since these exceptions have nothing to do with real exceptions
but are, like breakpoint execptions, expected and non-fatal, don't print
exception info for them.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-31 12:15:29 +02:00
Corinna Vinschen 472e5439e7 Fix passwd getting error 1265 when running on newer Windows
On Windows 8.1 and later, the NetUserChangePassword call apparently
doesn't accept the usual "\\server" string anymore, but requires to
use the "domain" instead, otherwise it emits en error code 1265,
ERROR_DOWNGRADE_DETECTED.  Since this is accepted by pre-8.1 as well,
use the domain indiscriminately when calling NetUserChangePassword
from passwd(1).

While at it, do some minor cleanup in passwd.c.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-31 12:08:34 +02:00
Yaakov Selkowitz abd37f0c79 Add release message for commit 3d3ab82
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-08-30 10:53:35 -05:00
Corinna Vinschen e97109184a Drop global __ctype_ptr__ entirely in favor of using locale_t::ctype_ptr
Keep __ctype_ptr__ available on Cygwin only, for backward compatibility
with existing apps referencing it via the ctype macros.

Otherwise initialize __global_locale.ctype_ptr and __C_locale.ctype_ptr
and use them throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-25 14:18:31 +02:00
Corinna Vinschen 988629da1d Fix formatting
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-25 12:06:17 +02:00
Jon Turney eccefd9704 Fix SetThreadName with current gdb
Wrap SetThreadName()'s call to RaiseException() in __try/__except/__endtry,
so that if the attached debugger doesn't know about MS_VC_EXCEPTION (e.g.
current gdb and probably strace as well) and continues exception processing,
we ignore it, rather than dying due an unhandled exception.

Also remove an unnecessary cast in the RaiseException() invocation.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-08-25 10:06:47 +01:00
Corinna Vinschen 2fd2f308e2 Include winsup.h prior to including other headers
Otherwise _GNU_SOURCE is not set when needed in sys/features.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-24 10:19:53 +02:00
Ken Brown 8ad852ac12 Clarify Cygwin's support for Win32 paths
See https://www.cygwin.com/ml/cygwin/2016-08/msg00431.html.
2016-08-23 20:29:20 +02:00
Corinna Vinschen 801fffcb7e Add missing LF in release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 18:57:16 +02:00
Corinna Vinschen 2ea3993619 Export and document strerror_l, strptime_l, wcsftime_l from Cygwin
Bump Cygwin API minor number.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Corinna Vinschen 0ecb846d2b Implement GNU extension strptime_l
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Corinna Vinschen e636fe3d48 Implement GNU extension wcsftime_l
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Corinna Vinschen 463a8afaa5 Implement missing POSIX-1.2008 function strerror_l
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Jon Turney 9e0f9ec7ae Send thread names to debugger
GDB since commit 24cdb46e [1] can report and use these names.

Add utility function SetThreadName(), which sends a thread name to the
debugger.

Use that:
- to set the default thread name for main thread and newly created pthreads.
- in pthread_setname_np() for user thread names.
- for helper thread names in cygthread::create()
- for helper threads which are created directly with CreateThread.

Note that there can still be anonymous threads, created by system or
injected DLLs.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24cdb46e9f0a694b4fbc11085e094857f08c0419
2016-08-23 15:07:42 +01:00
Jon Turney fdb7df230d Add pthread_getname_np and pthread_setname_np
This patch adds pthread_getname_np and pthread_setname_np.

These were added to glibc in 2.12[1] and are also present in some form on
NetBSD and several UNIXes.

The code is based on NetBSD's implementation with changes to better match
Linux behaviour.

Implementation quirks:

* pthread_setname_np with a NULL pointer segfaults (as linux)

* pthread_setname_np returns ERANGE for names longer than 16 characters (as
linux)

* pthread_getname_np with a NULL pointer returns EFAULT (as linux)

* pthread_getname_np with a buffer length of less than 16 returns ERANGE (as
linux)

* pthread_getname_np truncates the thread name to fit the buffer length.
This guarantees success even when the default thread name is longer than 16
characters, but means there is no way to discover the actual length of the
thread name. (Linux always truncates the thread name to 16 characters)

* Changing program_invocation_short_name changes the default thread name (on
linux, it has no effect on the default thread name)

I'll leave it up to you to decide if any of these matter.

This is implemented via class pthread_attr to make it easier to add
pthread_attr_[gs]etname_np (present in NetBSD and some UNIXes) should it
ever be added to Linux (or we decide we want it anyway).

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS
2016-08-23 15:07:42 +01:00
Corinna Vinschen 2fb5e3dfb2 Reference __global_locale only via __get_global_locale.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 12:38:28 +02:00
David Wohlferd 113abc27a6 Avoid truncating from long double to double in sinhl().
This routine makes a call to fabs instead of fabsl(), causing truncation.

Clang complains (warning: absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value).

Signed-off-by: David Wohlferd <dw@LimeGreenSocks.com>
2016-08-22 14:18:39 +02:00
Ray Donnelly 96fc528397 sqrt: Fix NaN propagation for IEEE Std 754-2008
The R language has some hacks specifically for mingw-w64 that
were caused by our handling of NaNs in sqrt(x). R uses a
special valued NaN to mean 'Not Available' and expects it to
be retained through various calculations. Our sqrt(x) doesn't
do this, instead it normalises such a NaN (retaining sign).

From:

http://wwwf.imperial.ac.uk/~drmii/M3SC_2016/IEEE_2008_4610935.pdf

"6.2.3 NaN propagation

An operation that propagates a NaN operand to its result and
has a single NaN as an input should produce a NaN with the
payload of the input NaN if representable in the destination
format."

There might even be a slight speed-up from this too.

Thanks to Duncan Murdoch for finding the reference.
2016-08-22 14:17:58 +02:00
Corinna Vinschen 0df76cbd63 Document nl_langinfo_l and separate POSIX from GNU extensions in release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:24:16 +02:00
Corinna Vinschen 216054fa77 Implement missing POSIX function nl_langinfo_l
Change nl_langinfo to nl_langinfo_l using locale given as argument.
Remove outdated TRANSITION_PERIOD_HACK.  The codeset is stored in
the locale for quite some time now.  For !MB_CAPABLE targets, just
return "US_ASCII" as codeset.

Implement nl_langinfo by calling nl_langinfo_l.  Export nl_langinfo_l
from Cygwin DLL and bump minor API version number.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:22:41 +02:00
Corinna Vinschen 7630e38462 Introduce __current_locale_charset/__locale_charset
The former __locale_charset always fetched the current locale's charset.
We need the per-locale charset, too, in future. Rename __locale_charset
to __current_locale_charset and change __locale_charset to take a
locale_t as parameter.  Accommodate througout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:14:56 +02:00
Corinna Vinschen 06ac671811 Only define __getreent inline function when building newlib or Cygwin
Commit 6f3943b erroneously removed the `#ifdef _COMPILING_NEWLIB'
guarding the __getreent inline function.  This patch ignored the
fact that config.h is included when building applications, and the
code in question requires internal, auto-generated headers to be
available which are not exposed to user-space.

Reinstantiate defined(_COMPILING_NEWLIB) test and alternatively
check for defined (__INSIDE_CYGWIN__), otherwise we'd have to
reinstantiate the __getreent macro in cygtls.h which is really
confusing.

While testing it turned out that a low number of source codes inside
Cygwin won't see the inline __getreent due to a missing __INSIDE_CYGWIN__
definition.  For malloc.cc this was actually deliberate to get different
definitions from including cygmalloc.h.  Change this by defining
__INSIDE_CYGWIN__ in malloc.cc but changing the test in cygmalloc.h
to test for defined(DLMALLOC_VERSION).  This might need a change if we
ever get around to replace dlmalloc with a newer, more threading-aware
malloc implementation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:14:55 +02:00
Corinna Vinschen 5e9b414e1c Add release message for commit eb61113
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-19 17:25:31 +02:00