diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index 9f849a791b..dcd9a75c49 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -106,6 +106,5 @@ jobs: make && make install && (cd */newlib; make info man) && - (cd */newlib; make install-info install-man) && - (cd */winsup; make check || true) + (cd */newlib; make install-info install-man) shell: C:\cygwin\bin\bash.exe --noprofile --norc -eo pipefail '{0}' diff --git a/newlib/libc/include/langinfo.h b/newlib/libc/include/langinfo.h index fcf986cce1..41d090d371 100644 --- a/newlib/libc/include/langinfo.h +++ b/newlib/libc/include/langinfo.h @@ -191,26 +191,26 @@ enum _NL_LOCALE_EXTENDED_FIRST_ENTRY, - _NL_CTYPE_OUTDIGITS0_MB, - _NL_CTYPE_OUTDIGITS1_MB, - _NL_CTYPE_OUTDIGITS2_MB, - _NL_CTYPE_OUTDIGITS3_MB, - _NL_CTYPE_OUTDIGITS4_MB, - _NL_CTYPE_OUTDIGITS5_MB, - _NL_CTYPE_OUTDIGITS6_MB, - _NL_CTYPE_OUTDIGITS7_MB, - _NL_CTYPE_OUTDIGITS8_MB, - _NL_CTYPE_OUTDIGITS9_MB, - _NL_CTYPE_OUTDIGITS0_WC, - _NL_CTYPE_OUTDIGITS1_WC, - _NL_CTYPE_OUTDIGITS2_WC, - _NL_CTYPE_OUTDIGITS3_WC, - _NL_CTYPE_OUTDIGITS4_WC, - _NL_CTYPE_OUTDIGITS5_WC, - _NL_CTYPE_OUTDIGITS6_WC, - _NL_CTYPE_OUTDIGITS7_WC, - _NL_CTYPE_OUTDIGITS8_WC, - _NL_CTYPE_OUTDIGITS9_WC, + _NL_CTYPE_OUTDIGIT0_MB, + _NL_CTYPE_OUTDIGIT1_MB, + _NL_CTYPE_OUTDIGIT2_MB, + _NL_CTYPE_OUTDIGIT3_MB, + _NL_CTYPE_OUTDIGIT4_MB, + _NL_CTYPE_OUTDIGIT5_MB, + _NL_CTYPE_OUTDIGIT6_MB, + _NL_CTYPE_OUTDIGIT7_MB, + _NL_CTYPE_OUTDIGIT8_MB, + _NL_CTYPE_OUTDIGIT9_MB, + _NL_CTYPE_OUTDIGIT0_WC, + _NL_CTYPE_OUTDIGIT1_WC, + _NL_CTYPE_OUTDIGIT2_WC, + _NL_CTYPE_OUTDIGIT3_WC, + _NL_CTYPE_OUTDIGIT4_WC, + _NL_CTYPE_OUTDIGIT5_WC, + _NL_CTYPE_OUTDIGIT6_WC, + _NL_CTYPE_OUTDIGIT7_WC, + _NL_CTYPE_OUTDIGIT8_WC, + _NL_CTYPE_OUTDIGIT9_WC, _NL_TIME_CODESET, _NL_TIME_WMON_1, diff --git a/newlib/libc/stdlib/gdtoa-dmisc.c b/newlib/libc/stdlib/gdtoa-dmisc.c index 332023dae9..f330f8ae7d 100644 --- a/newlib/libc/stdlib/gdtoa-dmisc.c +++ b/newlib/libc/stdlib/gdtoa-dmisc.c @@ -46,26 +46,28 @@ rv_alloc(ptr, i) struct _reent *ptr, int i; rv_alloc(struct _reent *ptr, int i) #endif { - int j, k, *r; + int j; + char *r; + /* Allocate buffer in a compatible way with legacy _ldtoa_r(). */ j = sizeof(ULong); - for(k = 0; - sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; - j <<= 1) - k++; - r = (int*)Balloc(ptr, k); + for (_REENT_MP_RESULT_K (ptr) = 0; + sizeof (Bigint) - sizeof (ULong) + j <= i; j <<= 1) + _REENT_MP_RESULT_K (ptr)++; + _REENT_MP_RESULT (ptr) = eBalloc (ptr, _REENT_MP_RESULT_K (ptr)); + r = (char *) _REENT_MP_RESULT (ptr); + if (r == NULL) return ( #ifndef MULTIPLE_THREADS dtoa_result = #endif NULL); - *r = k; return #ifndef MULTIPLE_THREADS dtoa_result = #endif - (char *)(r+1); + r; } char * @@ -100,8 +102,9 @@ freedtoa(ptr, s) struct _reent *ptr, char *s; freedtoa(struct _reent *ptr, char *s) #endif { - Bigint *b = (Bigint *)((int *)s - 1); - b->_maxwds = 1 << (b->_k = *(int*)b); + /* Free buffer allocated in a compatible way with legacy _ldtoa_r(). */ + Bigint *b = (Bigint *)s; + b->_maxwds = 1 << (b->_k = _REENT_MP_RESULT_K (ptr)); Bfree(ptr, b); #ifndef MULTIPLE_THREADS if (s == dtoa_result) diff --git a/newlib/libc/stdlib/gdtoa-ldtoa.c b/newlib/libc/stdlib/gdtoa-ldtoa.c index 14b99042ce..d5db270a67 100644 --- a/newlib/libc/stdlib/gdtoa-ldtoa.c +++ b/newlib/libc/stdlib/gdtoa-ldtoa.c @@ -72,9 +72,7 @@ _ldtoa_r(struct _reent *ptr, /* reentrancy addition to use mprec storage pool */ if (_REENT_MP_RESULT (ptr)) { - _REENT_MP_RESULT (ptr)->_k = _REENT_MP_RESULT_K (ptr); - _REENT_MP_RESULT (ptr)->_maxwds = 1 << _REENT_MP_RESULT_K (ptr); - Bfree (ptr, _REENT_MP_RESULT (ptr)); + freedtoa (ptr, (char *) _REENT_MP_RESULT (ptr)); _REENT_MP_RESULT (ptr) = 0; } diff --git a/winsup/configure.ac b/winsup/configure.ac index b299ab33fa..bacff0b794 100644 --- a/winsup/configure.ac +++ b/winsup/configure.ac @@ -149,10 +149,12 @@ AM_CONDITIONAL(CROSS_BOOTSTRAP, [test "x$with_cross_bootstrap" != "xyes"]) AC_EXEEXT -AC_CHECK_LIB([bfd], [bfd_init], [true], - AC_MSG_WARN([Not building dumper.exe since some required libraries or headers are missing])) +AC_ARG_ENABLE([dumper], + [AS_HELP_STRING([--disable-dumper], [do not build the 'dumper' utility])], + [build_dumper=$enableval], + [build_dumper=yes]) -AM_CONDITIONAL(BUILD_DUMPER, [test "x$ac_cv_lib_bfd_bfd_init" = "xyes"]) +AM_CONDITIONAL(BUILD_DUMPER, [test "x$build_dumper" = "xyes"]) # libbfd.a doesn't have a pkgconfig file, so we guess what it's dependencies # are, based on what's present in the build environment @@ -161,6 +163,11 @@ AC_CHECK_LIB([sframe], [sframe_decode], [BFD_LIBS="${BFD_LIBS} -lsframe"]) AC_CHECK_LIB([zstd], [ZSTD_isError], [BFD_LIBS="${BFD_LIBS} -lzstd"]) AC_SUBST([BFD_LIBS]) +AC_CHECK_LIB([sframe], [sframe_decode], + AC_MSG_NOTICE([Detected libsframe; Assuming that libbfd depends on it]), [true]) + +AM_CONDITIONAL(HAVE_LIBSFRAME, [test "x$ac_cv_lib_sframe_sframe_decode" = "xyes"]) + AC_CONFIG_FILES([ Makefile cygwin/Makefile diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index a2a4406b66..0f332b447b 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -49,6 +49,8 @@ __b64_ntop NOSIGFE __b64_pton NOSIGFE __bsd_qsort_r NOSIGFE __chk_fail SIGFE +__cpuset_alloc SIGFE +__cpuset_free SIGFE __cxa_atexit = cygwin__cxa_atexit SIGFE __cxa_finalize SIGFE __dn_comp SIGFE diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index a577832a8a..84a1cda498 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -989,13 +989,22 @@ dll_crt0_1 (void *) { /* Create a copy of Cygwin's version of __argv so that, if the user makes a change to an element of argv[] it does not affect Cygwin's argv. - Changing the the contents of what argv[n] points to will still - affect Cygwin. This is similar (but not exactly like) Linux. */ - char *newargv[__argc + 1]; - char **nav = newargv; - char **oav = __argv; - while ((*nav++ = *oav++) != NULL) - continue; + Changing the contents of what argv[n] points to will still affect + Cygwin. This is similar (but not exactly like) Linux. + + We used to allocate newargv on the stack, but all the rest of the + argument and environment handling does not depend on the stack, + as it does on Linux. In fact, everything is stored by the parent + in the cygheap, so the only reason this may fail is if we're out + of resources in a big way. If this malloc fails, we could either + fail the entire process execution, or we could proceed with the + original argv and potentially affect output of /proc/self/cmdline. + We opt for the latter here because it's the lesser evil. */ + char **newargv = (char **) malloc ((__argc + 1) * sizeof (char *)); + if (newargv) + memcpy (newargv, __argv, (__argc + 1) * sizeof (char *)); + else + newargv = __argv; /* Handle any signals which may have arrived */ sig_dispatch_pending (false); _my_tls.call_signal_handler (); diff --git a/winsup/cygwin/fhandler/dsp.cc b/winsup/cygwin/fhandler/dsp.cc index db7b2550ec..dbe27905a9 100644 --- a/winsup/cygwin/fhandler/dsp.cc +++ b/winsup/cygwin/fhandler/dsp.cc @@ -1062,7 +1062,7 @@ fhandler_dev_dsp::fixup_after_exec () int fhandler_dev_dsp::open (int flags, mode_t) { - int ret = 0, err = 0; + int ret = -1, err = 0; UINT num_in = 0, num_out = 0; set_flags ((flags & ~O_TEXT) | O_BINARY); // Work out initial sample format & frequency, /dev/dsp defaults @@ -1095,7 +1095,7 @@ fhandler_dev_dsp::open (int flags, mode_t) debug_printf ("ACCMODE=%y audio_in=%d audio_out=%d, err=%d, ret=%d", flags & O_ACCMODE, num_in, num_out, err, ret); - if (ret) + if (ret >= 0) being_closed = false; return ret; } @@ -1188,7 +1188,9 @@ fhandler_dev_dsp::_read (void *ptr, size_t& len) return; } - audio_in_->read ((char *)ptr, (int&)len); + int res = len; + audio_in_->read ((char *)ptr, res); + len = (size_t)res; } void diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index 01721e3a80..dbeffc9e3f 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -85,7 +85,8 @@ inline static bool process_alive (DWORD pid); stub_only: return only stub process's pid of non-cygwin process. */ DWORD fhandler_pty_common::get_console_process_id (DWORD pid, bool match, - bool cygwin, bool stub_only) + bool cygwin, bool stub_only, + bool nat) { tmp_pathbuf tp; DWORD *list = (DWORD *) tp.c_get (); @@ -109,6 +110,8 @@ fhandler_pty_common::get_console_process_id (DWORD pid, bool match, else { pinfo p (cygwin_pid (list[i])); + if (nat && !!p && !ISSTATE(p, PID_NOTCYGWIN)) + continue; if (!!p && p->exec_dwProcessId) { res_pri = stub_only ? p->exec_dwProcessId : list[i]; @@ -436,8 +439,10 @@ static int osi; void fhandler_pty_master::flush_to_slave () { + WaitForSingleObject (input_mutex, mutex_timeout); if (get_readahead_valid () && !(get_ttyp ()->ti.c_lflag & ICANON)) accept_input (); + ReleaseMutex (input_mutex); } void @@ -523,8 +528,6 @@ fhandler_pty_master::accept_input () DWORD bytes_left; int ret = 1; - WaitForSingleObject (input_mutex, mutex_timeout); - char *p = rabuf () + raixget (); bytes_left = eat_readahead (-1); @@ -626,7 +629,6 @@ fhandler_pty_master::accept_input () if (write_to == get_output_handle ()) SetEvent (input_available_event); /* Set input_available_event only when the data is written to cyg pipe. */ - ReleaseMutex (input_mutex); return ret; } @@ -2247,9 +2249,9 @@ fhandler_pty_master::write (const void *ptr, size_t len) { /* This accept_input() call is needed in order to transfer input which is not accepted yet to non-cygwin pipe. */ + WaitForSingleObject (input_mutex, mutex_timeout); if (get_readahead_valid ()) accept_input (); - WaitForSingleObject (input_mutex, mutex_timeout); acquire_attach_mutex (mutex_timeout); fhandler_pty_slave::transfer_input (tty::to_nat, from_master, get_ttyp (), @@ -2317,9 +2319,10 @@ fhandler_pty_master::write (const void *ptr, size_t len) get_ttyp (), input_available_event); release_attach_mutex (); } - ReleaseMutex (input_mutex); line_edit_status status = line_edit (p, len, ti, &ret); + ReleaseMutex (input_mutex); + if (status > line_edit_signalled && status != line_edit_pipe_full) ret = -1; return ret; @@ -3577,9 +3580,11 @@ fhandler_pty_slave::get_winpid_to_hand_over (tty *ttyp, { /* Search another native process which attaches to the same console */ DWORD current_pid = myself->exec_dwProcessId ?: myself->dwProcessId; - switch_to = get_console_process_id (current_pid, false, true, true); + switch_to = get_console_process_id (current_pid, + false, true, true, true); if (!switch_to) - switch_to = get_console_process_id (current_pid, false, true, false); + switch_to = get_console_process_id (current_pid, + false, true, false, true); } return switch_to; } @@ -3902,7 +3907,9 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir, HANDLE from, tty *ttyp, to = ttyp->to_slave (); pinfo p (ttyp->master_pid); - HANDLE pty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProcessId); + HANDLE pty_owner = NULL; + if (p) + pty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProcessId); if (pty_owner) { DuplicateHandle (pty_owner, to, GetCurrentProcess (), &to, diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 79f2b418c6..2e08a9dd6a 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -11,7 +11,7 @@ details. */ changes to the DLL and is mainly informative in nature. */ #define CYGWIN_VERSION_DLL_MAJOR 3004 -#define CYGWIN_VERSION_DLL_MINOR 7 +#define CYGWIN_VERSION_DLL_MINOR 9 /* CYGWIN_VERSION_DLL_COMBINED gives us a single number representing the combined DLL major and minor numbers. */ diff --git a/winsup/cygwin/include/sys/cpuset.h b/winsup/cygwin/include/sys/cpuset.h index d83359fdf3..a5a8fa81ef 100644 --- a/winsup/cygwin/include/sys/cpuset.h +++ b/winsup/cygwin/include/sys/cpuset.h @@ -9,14 +9,16 @@ details. */ #ifndef _SYS_CPUSET_H_ #define _SYS_CPUSET_H_ +#include + #ifdef __cplusplus extern "C" { #endif typedef __SIZE_TYPE__ __cpu_mask; -#define __CPU_SETSIZE 1024 // maximum number of logical processors tracked -#define __NCPUBITS (8 * sizeof (__cpu_mask)) // max size of processor group -#define __CPU_GROUPMAX (__CPU_SETSIZE / __NCPUBITS) // maximum group number +#define __CPU_SETSIZE 1024 /* maximum number of logical processors tracked */ +#define __NCPUBITS (8 * sizeof (__cpu_mask)) /* max size of processor group */ +#define __CPU_GROUPMAX (__CPU_SETSIZE / __NCPUBITS) /* maximum group number */ #define __CPUELT(cpu) ((cpu) / __NCPUBITS) #define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS)) @@ -27,58 +29,56 @@ typedef struct } cpu_set_t; #if __GNU_VISIBLE -int __sched_getaffinity_sys (pid_t, size_t, cpu_set_t *); +int __sched_getaffinity_sys (__pid_t, __size_t, cpu_set_t *); /* These macros alloc or free dynamically-sized cpu sets of size 'num' cpus. Allocations are padded such that full-word operations can be done easily. */ #define CPU_ALLOC_SIZE(num) __cpuset_alloc_size (num) -static inline size_t +static __inline __size_t __cpuset_alloc_size (int num) { - return (size_t) (((num + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask)); + return (__size_t) (((num + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask)); } #define CPU_ALLOC(num) __cpuset_alloc (num) -static inline cpu_set_t * -__cpuset_alloc (int num) -{ - return (cpu_set_t *) __builtin_malloc (CPU_ALLOC_SIZE(num)); -} +extern cpu_set_t * __cpuset_alloc (int); #define CPU_FREE(set) __cpuset_free (set) -static inline void -__cpuset_free (cpu_set_t *set) -{ - __builtin_free (set); -} +void __cpuset_free (cpu_set_t *); /* These _S macros operate on dynamically-sized cpu sets of size 'siz' bytes */ #define CPU_ZERO_S(siz, set) __cpuset_zero_s (siz, set) -static inline void -__cpuset_zero_s (size_t siz, cpu_set_t *set) +static __inline +__cpuset_zero_s (__size_t siz, cpu_set_t *set) { - (void) __builtin_memset (set, 0, siz); +#if __GNUC_PREREQ (2, 91) + __builtin_memset (set, 0, siz); +#else + siz /= sizeof (__cpu_mask); + while (siz > 0) + set->_bits[--siz] = 0; +#endif } #define CPU_SET_S(cpu, siz, set) __cpuset_set_s (cpu, siz, set) -static inline void -__cpuset_set_s (int cpu, size_t siz, cpu_set_t *set) +static __inline void +__cpuset_set_s (int cpu, __size_t siz, cpu_set_t *set) { if (cpu >= 0 && cpu < 8 * siz) (set)->__bits[__CPUELT(cpu)] |= __CPUMASK(cpu); } #define CPU_CLR_S(cpu, siz, set) __cpuset_clr_s (cpu, siz, set) -static inline void -__cpuset_clr_s (int cpu, size_t siz, cpu_set_t *set) +static __inline void +__cpuset_clr_s (int cpu, __size_t siz, cpu_set_t *set) { if (cpu >= 0 && cpu < 8 * siz) (set)->__bits[__CPUELT(cpu)] &= ~(__CPUMASK(cpu)); } #define CPU_ISSET_S(cpu, siz, set) __cpuset_isset_s (cpu, siz, set) -static inline int -__cpuset_isset_s (int cpu, size_t siz, cpu_set_t *set) +static __inline int +__cpuset_isset_s (int cpu, __size_t siz, cpu_set_t *set) { int res = 0; if (cpu >= 0 && cpu < 8 * siz) @@ -87,45 +87,48 @@ __cpuset_isset_s (int cpu, size_t siz, cpu_set_t *set) } #define CPU_COUNT_S(siz, set) __cpuset_count_s (siz, set) -static inline int -__cpuset_count_s (size_t siz, cpu_set_t *set) +static __inline int +__cpuset_count_s (__size_t siz, cpu_set_t *set) { - int res = 0; - for (int i = 0; i < siz / sizeof (__cpu_mask); i++) + int i, res = 0; + for (i = 0; i < siz / sizeof (__cpu_mask); i++) res += __builtin_popcountl ((set)->__bits[i]); return res; } #define CPU_AND_S(siz, dst, src1, src2) __cpuset_and_s (siz, dst, src1, src2) -static inline void -__cpuset_and_s (size_t siz, cpu_set_t *dst, cpu_set_t *src1, cpu_set_t *src2) +static __inline void +__cpuset_and_s (__size_t siz, cpu_set_t *dst, cpu_set_t *src1, cpu_set_t *src2) { - for (int i = 0; i < siz / sizeof (__cpu_mask); i++) + int i; + for (i = 0; i < siz / sizeof (__cpu_mask); i++) (dst)->__bits[i] = (src1)->__bits[i] & (src2)->__bits[i]; } #define CPU_OR_S(siz, dst, src1, src2) __cpuset_or_s (siz, dst, src1, src2) -static inline void -__cpuset_or_s (size_t siz, cpu_set_t *dst, cpu_set_t *src1, cpu_set_t *src2) +static __inline void +__cpuset_or_s (__size_t siz, cpu_set_t *dst, cpu_set_t *src1, cpu_set_t *src2) { - for (int i = 0; i < siz / sizeof (__cpu_mask); i++) + int i; + for (i = 0; i < siz / sizeof (__cpu_mask); i++) (dst)->__bits[i] = (src1)->__bits[i] | (src2)->__bits[i]; } #define CPU_XOR_S(siz, dst, src1, src2) __cpuset_xor_s (siz, dst, src1, src2) -static inline void -__cpuset_xor_s (size_t siz, cpu_set_t *dst, cpu_set_t *src1, cpu_set_t *src2) +static __inline void +__cpuset_xor_s (__size_t siz, cpu_set_t *dst, cpu_set_t *src1, cpu_set_t *src2) { - for (int i = 0; i < siz / sizeof (__cpu_mask); i++) + int i; + for (i = 0; i < siz / sizeof (__cpu_mask); i++) (dst)->__bits[i] = (src1)->__bits[i] ^ (src2)->__bits[i]; } #define CPU_EQUAL_S(siz, src1, src2) __cpuset_equal_s (siz, src1, src2) -static inline int -__cpuset_equal_s (size_t siz, cpu_set_t *src1, cpu_set_t *src2) +static __inline int +__cpuset_equal_s (__size_t siz, cpu_set_t *src1, cpu_set_t *src2) { - int res = 1; - for (int i = 0; res && i < siz / sizeof (__cpu_mask); i++) + int i, res = 1; + for (i = 0; res && i < siz / sizeof (__cpu_mask); i++) res &= (src1)->__bits[i] == (src2)->__bits[i]; return res; } diff --git a/winsup/cygwin/kernel32.cc b/winsup/cygwin/kernel32.cc index 6248aefd51..36951f6a87 100644 --- a/winsup/cygwin/kernel32.cc +++ b/winsup/cygwin/kernel32.cc @@ -424,8 +424,11 @@ ucmd () linebuf cmd; path_conv real_path (__argv[0]); av newargv (__argc, __argv); - cmd.fromargv (newargv, real_path.get_win32 (), true); - RtlInitUnicodeString (&wcmd, cmd); + if (newargv.argc) + { + cmd.fromargv (newargv, real_path.get_win32 (), true); + RtlInitUnicodeString (&wcmd, cmd); + } } return &wcmd; } diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_includes/fhandler.h index e7315ae16d..649a431844 100644 --- a/winsup/cygwin/local_includes/fhandler.h +++ b/winsup/cygwin/local_includes/fhandler.h @@ -2377,7 +2377,8 @@ class fhandler_pty_common: public fhandler_termios void resize_pseudo_console (struct winsize *); static DWORD get_console_process_id (DWORD pid, bool match, bool cygwin = false, - bool stub_only = false); + bool stub_only = false, + bool nat = false); bool to_be_read_from_nat_pipe (void); static DWORD attach_console_temporarily (DWORD target_pid, DWORD helper_pid); static void resume_from_temporarily_attach (DWORD resume_pid); @@ -2550,6 +2551,14 @@ class fhandler_pty_master: public fhandler_pty_common int tcgetpgrp (); void flush_to_slave (); void discard_input (); + void acquire_input_mutex_if_necessary (DWORD ms) + { + WaitForSingleObject (input_mutex, ms); + } + void release_input_mutex_if_necessary (void) + { + ReleaseMutex (input_mutex); + } fhandler_pty_master (void *) {} @@ -2782,6 +2791,8 @@ class fhandler_dev_dsp: public fhandler_base void close_audio_in (); void close_audio_out (bool = false); + + public: bool use_archetype () const {return true;} fhandler_dev_dsp (void *) {} diff --git a/winsup/cygwin/local_includes/winf.h b/winsup/cygwin/local_includes/winf.h index 38719f3bcd..bc53cd1aa3 100644 --- a/winsup/cygwin/local_includes/winf.h +++ b/winsup/cygwin/local_includes/winf.h @@ -23,11 +23,16 @@ class av public: int argc; bool win16_exe; - av (): argv (NULL) {} - av (int ac_in, const char * const *av_in) : calloced (0), argc (ac_in), win16_exe (false) + av () : argv (NULL), argc (0) {} + av (int ac_in, const char * const *av_in) + : calloced (0), win16_exe (false) { - argv = (char **) cmalloc_abort (HEAP_1_ARGV, (argc + 5) * sizeof (char *)); - memcpy (argv, av_in, (argc + 1) * sizeof (char *)); + argv = (char **) cmalloc (HEAP_1_ARGV, (ac_in + 5) * sizeof (char *)); + if (argv) + { + argc = ac_in; + memcpy (argv, av_in, (argc + 1) * sizeof (char *)); + } } void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;} ~av () diff --git a/winsup/cygwin/mm/shared.cc b/winsup/cygwin/mm/shared.cc index 2ea3a43363..20b57ff4d3 100644 --- a/winsup/cygwin/mm/shared.cc +++ b/winsup/cygwin/mm/shared.cc @@ -148,8 +148,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h, DWORD size, if (name) mapname = shared_name (map_buf, name, n); if (m == SH_JUSTOPEN) - shared_h = OpenFileMappingW (FILE_MAP_READ | FILE_MAP_WRITE, FALSE, - mapname); + shared_h = OpenFileMappingW (access, FALSE, mapname); else { created = true; @@ -175,8 +174,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h, DWORD size, Note that we don't actually *need* fixed addresses. The only advantage is reproducibility to help /proc//maps along. */ addr = (void *) region_address[m]; - shared = MapViewOfFileEx (shared_h, FILE_MAP_READ | FILE_MAP_WRITE, - 0, 0, 0, addr); + shared = MapViewOfFileEx (shared_h, access, 0, 0, 0, addr); } /* Also catch the unlikely case that a fixed region can't be mapped at the fixed address. */ @@ -190,8 +188,7 @@ open_shared (const WCHAR *name, int n, HANDLE& shared_h, DWORD size, do { addr = (void *) next_address; - shared = MapViewOfFileEx (shared_h, FILE_MAP_READ | FILE_MAP_WRITE, - 0, 0, 0, addr); + shared = MapViewOfFileEx (shared_h, access, 0, 0, 0, addr); next_address += wincap.allocation_granularity (); if (next_address >= SHARED_REGIONS_ADDRESS_HIGH) { diff --git a/winsup/cygwin/release/3.4.8 b/winsup/cygwin/release/3.4.8 new file mode 100644 index 0000000000..8cd3eb14be --- /dev/null +++ b/winsup/cygwin/release/3.4.8 @@ -0,0 +1,22 @@ +Bug Fixes +--------- + +- Make safe for c89 compilations. + Addresses: https://cygwin.com/pipermail/cygwin-patches/2023q3/012308.html + +- Make gcc-specific code in compiler-agnostic. + Addresses: https://cygwin.com/pipermail/cygwin/2023-July/253927.html + +- Fix AT_EMPTY_PATH handling in fchmodat and fstatat if dirfd referres to + a file other than a directory + Addresses: https://cygwin.com/pipermail/cygwin-patches/2023q2/012306.html + +- Rename internal macros _NL_CTYPE_OUTDIGITSx_MB/WC to GLibc compatible + _NL_CTYPE_OUTDIGITx_MB/WC. + Addresses: https://cygwin.com/pipermail/cygwin-developers/2023-July/012637.html + +- Fix memory leak in printf() regarding gdtoa-based _ldtoa_r(). + Addresses: https://cygwin.com/pipermail/cygwin/2023-July/254054.html + +- Fix a bug introduced in cygwin 3.4.5 that open_shared() does not set + access permissions as requested by its argument. diff --git a/winsup/cygwin/release/3.4.9 b/winsup/cygwin/release/3.4.9 new file mode 100644 index 0000000000..e2b0647464 --- /dev/null +++ b/winsup/cygwin/release/3.4.9 @@ -0,0 +1,16 @@ +Bug Fixes +--------- + +- Fix a bug introduced in cygwin 3.4.0 that switch_to_nat_pipe flag is + not cleared properly when non-cygwin app is terminated in the case + where pseudo console is not activated. + +- For the time being, disable creating special files using mknod/mkfifo + on NFS. + Addresses: https://cygwin.com/pipermail/cygwin/2023-August/254266.html + +- Fix segfault when too many command line args are specified. + Addresses: https://cygwin.com/pipermail/cygwin/2023-August/254333.html + +- Fix build problems in terms of sys/cpuset.h. + Addresses: https://cygwin.com/pipermail/cygwin/2023-August/254283.html diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc index d7bad85276..845fcef570 100644 --- a/winsup/cygwin/sched.cc +++ b/winsup/cygwin/sched.cc @@ -684,4 +684,16 @@ sched_setaffinity (pid_t pid, size_t sizeof_set, const cpu_set_t *set) return 0; } +cpu_set_t * +__cpuset_alloc (int num) +{ + return (cpu_set_t *) malloc (CPU_ALLOC_SIZE(num)); +} + +void +__cpuset_free (cpu_set_t *set) +{ + free (set); +} + } /* extern C */ diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index e0770aeddc..383f5e56fe 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -354,7 +354,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, int ac; for (ac = 0; argv[ac]; ac++) - /* nothing */; + ; int err; const char *ext; @@ -1142,11 +1142,16 @@ spawnvpe (int mode, const char *file, const char * const *argv, int av::setup (const char *prog_arg, path_conv& real_path, const char *ext, - int argc, const char *const *argv, bool p_type_exec) + int ac_in, const char *const *av_in, bool p_type_exec) { const char *p; bool exeext = ascii_strcasematch (ext, ".exe"); - new (this) av (argc, argv); + new (this) av (ac_in, av_in); + if (!argc) + { + set_errno (E2BIG); + return -1; + } if ((exeext && real_path.iscygexec ()) || ascii_strcasematch (ext, ".bat") || (!*ext && ((p = ext - 4) > real_path.get_win32 ()) && (ascii_strcasematch (p, ".bat") || ascii_strcasematch (p, ".cmd") diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 068aeebf7e..ef6bb0dd38 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -3292,6 +3292,12 @@ mknod (const char *path, mode_t mode, dev_t dev) __leave; } + if (w32path.fs_is_nfs ()) + { + set_errno (EPERM); + __leave; + } + return mknod_worker (w32path, mode, major, minor); } __except (EFAULT) diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index 2db92e4def..6529731a51 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -485,7 +485,7 @@ static struct }; } sca[] = { - {cons, {c:ARG_MAX}}, /* 0, _SC_ARG_MAX */ + {cons, {c:-1L}}, /* 0, _SC_ARG_MAX */ {cons, {c:CHILD_MAX}}, /* 1, _SC_CHILD_MAX */ {cons, {c:CLOCKS_PER_SEC}}, /* 2, _SC_CLK_TCK */ {cons, {c:NGROUPS_MAX}}, /* 3, _SC_NGROUPS_MAX */ diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 5c1284a936..f614e01c42 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -364,7 +364,7 @@ void pthread::init_mainthread () { pthread *thread = _my_tls.tid; - if (!thread) + if (!thread || thread == pthread_null::get_null_pthread ()) { thread = new pthread (); if (!thread) diff --git a/winsup/doc/faq-programming.xml b/winsup/doc/faq-programming.xml index d23f32c3a7..478cf997f8 100644 --- a/winsup/doc/faq-programming.xml +++ b/winsup/doc/faq-programming.xml @@ -679,8 +679,14 @@ rewriting the runtime library in question from specs... installed; you at least need gcc-g++, make, automake, autoconf, git, perl, -gettext-devel, libiconv-devel, libzstd-devel, -zlib-devel, cocom and patch. +cocom and patch. + + + +Additionally, building the dumper utility requires +gettext-devel, libiconv-devel, libzstd-devel and +zlib-devel. Building this program can be disabled with the +--disable-dumper option to configure. diff --git a/winsup/utils/Makefile.am b/winsup/utils/Makefile.am index fa6499dfee..f10335eef5 100644 --- a/winsup/utils/Makefile.am +++ b/winsup/utils/Makefile.am @@ -88,6 +88,10 @@ profiler_CXXFLAGS = -I$(srcdir) -idirafter ${top_srcdir}/cygwin/local_includes - profiler_LDADD = $(LDADD) -lntdll cygps_LDADD = $(LDADD) -lpsapi -lntdll +if HAVE_LIBSFRAME +dumper_LDADD += -lsframe +endif + if CROSS_BOOTSTRAP SUBDIRS = mingw endif diff --git a/winsup/utils/locale.cc b/winsup/utils/locale.cc index 3f7e5dcca6..d3655169dd 100644 --- a/winsup/utils/locale.cc +++ b/winsup/utils/locale.cc @@ -546,26 +546,26 @@ lc_names_t lc_ctype_names[] = { { "ctype-class-names", is_string_fake, 0, 0 }, { "ctype-map-names", is_string_fake, 2, 0 }, - { "ctype-outdigit0_mb", is_string, _NL_CTYPE_OUTDIGITS0_MB, 0 }, - { "ctype-outdigit1_mb", is_string, _NL_CTYPE_OUTDIGITS1_MB, 0 }, - { "ctype-outdigit2_mb", is_string, _NL_CTYPE_OUTDIGITS2_MB, 0 }, - { "ctype-outdigit3_mb", is_string, _NL_CTYPE_OUTDIGITS3_MB, 0 }, - { "ctype-outdigit4_mb", is_string, _NL_CTYPE_OUTDIGITS4_MB, 0 }, - { "ctype-outdigit5_mb", is_string, _NL_CTYPE_OUTDIGITS5_MB, 0 }, - { "ctype-outdigit6_mb", is_string, _NL_CTYPE_OUTDIGITS6_MB, 0 }, - { "ctype-outdigit7_mb", is_string, _NL_CTYPE_OUTDIGITS7_MB, 0 }, - { "ctype-outdigit8_mb", is_string, _NL_CTYPE_OUTDIGITS8_MB, 0 }, - { "ctype-outdigit9_mb", is_string, _NL_CTYPE_OUTDIGITS9_MB, 0 }, - { "ctype-outdigit0_wc", is_wchar, _NL_CTYPE_OUTDIGITS0_WC, 0 }, - { "ctype-outdigit1_wc", is_wchar, _NL_CTYPE_OUTDIGITS1_WC, 0 }, - { "ctype-outdigit2_wc", is_wchar, _NL_CTYPE_OUTDIGITS2_WC, 0 }, - { "ctype-outdigit3_wc", is_wchar, _NL_CTYPE_OUTDIGITS3_WC, 0 }, - { "ctype-outdigit4_wc", is_wchar, _NL_CTYPE_OUTDIGITS4_WC, 0 }, - { "ctype-outdigit5_wc", is_wchar, _NL_CTYPE_OUTDIGITS5_WC, 0 }, - { "ctype-outdigit6_wc", is_wchar, _NL_CTYPE_OUTDIGITS6_WC, 0 }, - { "ctype-outdigit7_wc", is_wchar, _NL_CTYPE_OUTDIGITS7_WC, 0 }, - { "ctype-outdigit8_wc", is_wchar, _NL_CTYPE_OUTDIGITS8_WC, 0 }, - { "ctype-outdigit9_wc", is_wchar, _NL_CTYPE_OUTDIGITS9_WC, 0 }, + { "ctype-outdigit0_mb", is_string, _NL_CTYPE_OUTDIGIT0_MB, 0 }, + { "ctype-outdigit1_mb", is_string, _NL_CTYPE_OUTDIGIT1_MB, 0 }, + { "ctype-outdigit2_mb", is_string, _NL_CTYPE_OUTDIGIT2_MB, 0 }, + { "ctype-outdigit3_mb", is_string, _NL_CTYPE_OUTDIGIT3_MB, 0 }, + { "ctype-outdigit4_mb", is_string, _NL_CTYPE_OUTDIGIT4_MB, 0 }, + { "ctype-outdigit5_mb", is_string, _NL_CTYPE_OUTDIGIT5_MB, 0 }, + { "ctype-outdigit6_mb", is_string, _NL_CTYPE_OUTDIGIT6_MB, 0 }, + { "ctype-outdigit7_mb", is_string, _NL_CTYPE_OUTDIGIT7_MB, 0 }, + { "ctype-outdigit8_mb", is_string, _NL_CTYPE_OUTDIGIT8_MB, 0 }, + { "ctype-outdigit9_mb", is_string, _NL_CTYPE_OUTDIGIT9_MB, 0 }, + { "ctype-outdigit0_wc", is_wchar, _NL_CTYPE_OUTDIGIT0_WC, 0 }, + { "ctype-outdigit1_wc", is_wchar, _NL_CTYPE_OUTDIGIT1_WC, 0 }, + { "ctype-outdigit2_wc", is_wchar, _NL_CTYPE_OUTDIGIT2_WC, 0 }, + { "ctype-outdigit3_wc", is_wchar, _NL_CTYPE_OUTDIGIT3_WC, 0 }, + { "ctype-outdigit4_wc", is_wchar, _NL_CTYPE_OUTDIGIT4_WC, 0 }, + { "ctype-outdigit5_wc", is_wchar, _NL_CTYPE_OUTDIGIT5_WC, 0 }, + { "ctype-outdigit6_wc", is_wchar, _NL_CTYPE_OUTDIGIT6_WC, 0 }, + { "ctype-outdigit7_wc", is_wchar, _NL_CTYPE_OUTDIGIT7_WC, 0 }, + { "ctype-outdigit8_wc", is_wchar, _NL_CTYPE_OUTDIGIT8_WC, 0 }, + { "ctype-outdigit9_wc", is_wchar, _NL_CTYPE_OUTDIGIT9_WC, 0 }, { "charmap", is_string, CODESET, 0 }, { "ctype-mb-cur-max", is_int, _NL_CTYPE_MB_CUR_MAX, 0 }, { NULL, is_end, 0, 0 }