diff options
-rw-r--r-- | .github/workflows/cygwin.yml | 22 | ||||
-rw-r--r-- | newlib/libc/machine/riscv/strlen.c | 14 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/fhandler/console.cc | 33 | ||||
-rw-r--r-- | winsup/cygwin/local_includes/cygtls.h | 2 | ||||
-rw-r--r-- | winsup/doc/path.xml | 21 | ||||
-rwxr-xr-x | winsup/testsuite/stress/cygstress | 2 |
7 files changed, 66 insertions, 37 deletions
diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index fa00834..f45e652 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -204,14 +204,18 @@ jobs: windows-stress-test: needs: windows-build - runs-on: windows-latest strategy: fail-fast: false matrix: include: - - target: x86_64-pc-cygwin - pkgarch: x86_64 - name: Windows tests ${{ matrix.pkgarch }} + - pkgarch: x86_64 + runarch: x86_64 + runner: windows-latest + - pkgarch: x86_64 + runarch: arm64 + runner: windows-11-arm + runs-on: ${{ matrix.runner }} + name: Windows tests ${{ matrix.pkgarch }} on ${{ matrix.runarch }} steps: - run: git config --global core.autocrlf input @@ -219,6 +223,7 @@ jobs: # install cygwin - name: Install Cygwin + id: cygwin-install uses: cygwin/cygwin-install-action@master with: platform: ${{ matrix.pkgarch }} @@ -233,9 +238,9 @@ jobs: uses: actions/download-artifact@v4 with: name: cygwin-install-${{ matrix.pkgarch }} - # the path specified here should match the install-dir of - # cygwin-install-action above, so we unpack the artifact over it - path: 'D:\cygwin' + # use the install-dir of cygwin-install-action above, so we unpack the + # artifact over it + path: ${{ steps.cygwin-install.outputs.root }} # This isn't quite right, as it just overwrites existing files, it doesn't # remove anything which is no longer provided. Ideally, we'd make a cygwin @@ -250,12 +255,13 @@ jobs: export LOGDIR=$(cygpath -a logs) winsup/testsuite/stress/cygstress CI shell: bash --noprofile --norc -o igncr -eo pipefail '{0}' + continue-on-error: ${{ matrix.runarch == 'arm64' }} # upload logs artifact - name: Capture logs artifact uses: actions/upload-artifact@v4 with: - name: stress-logs-${{ matrix.pkgarch }} + name: stress-logs-${{ matrix.pkgarch }}-on-${{ matrix.runarch }} path: | logs if: ${{ !cancelled() }} diff --git a/newlib/libc/machine/riscv/strlen.c b/newlib/libc/machine/riscv/strlen.c index 9bfd2a1..9f1be1b 100644 --- a/newlib/libc/machine/riscv/strlen.c +++ b/newlib/libc/machine/riscv/strlen.c @@ -47,16 +47,16 @@ size_t strlen(const char *str) return ret + (psval >> 3) - sp; #else char c0 = str[0 - sp], c1 = str[1 - sp], c2 = str[2 - sp], c3 = str[3 - sp]; - if (c0 == 0) return ret + 0 - sp; - if (c1 == 0) return ret + 1 - sp; - if (c2 == 0) return ret + 2 - sp; - if (c3 == 0) return ret + 3 - sp; + if (c0 == 0) return ret + 0 - sp; + if (c1 == 0) return ret + 1 - sp; + if (c2 == 0) return ret + 2 - sp; + if (__riscv_xlen == 32 || c3 == 0) return ret + 3 - sp; #if __riscv_xlen == 64 c0 = str[4 - sp], c1 = str[5 - sp], c2 = str[6 - sp]; - if (c0 == 0) return ret + 4 - sp; - if (c1 == 0) return ret + 5 - sp; - if (c2 == 0) return ret + 6 - sp; + if (c0 == 0) return ret + 4 - sp; + if (c1 == 0) return ret + 5 - sp; + if (c2 == 0) return ret + 6 - sp; #endif return ret + 7 - sp; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index d1c98e4..9763a1b 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -440,7 +440,7 @@ cygwin_exception::dumpstack () } bool -_cygtls::inside_kernel (CONTEXT *cx) +_cygtls::inside_kernel (CONTEXT *cx, bool inside_cygwin) { int res; MEMORY_BASIC_INFORMATION m; @@ -462,6 +462,8 @@ _cygtls::inside_kernel (CONTEXT *cx) else if (h == hntdll) res = true; /* Calling GetModuleFilename on ntdll.dll can hang */ + else if (h == cygwin_hmodule && inside_cygwin) + res = true; else if (h == user_data->hmodule) res = false; else if (!GetModuleFileNameW (h, checkdir, @@ -921,7 +923,7 @@ _cygtls::interrupt_now (CONTEXT *cx, siginfo_t& si, void *handler, /* Delay the interrupt if we are 1) somehow inside the DLL 2) in a Windows DLL. */ - if (incyg || inside_kernel (cx)) + if (incyg || inside_kernel (cx, true)) interrupted = false; else { @@ -1756,6 +1758,7 @@ _cygtls::call_signal_handler () int this_errno = saved_errno; reset_signal_arrived (); + incyg = false; current_sig = 0; /* Flag that we can accept another signal */ /* We have to fetch the original return address from the signal stack @@ -1868,6 +1871,8 @@ _cygtls::call_signal_handler () } unlock (); + incyg = true; + set_signal_mask (_my_tls.sigmask, (this_sa_flags & SA_SIGINFO) ? context1.uc_sigmask : this_oldmask); if (this_errno >= 0) diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc index 2e19e0d..16352d0 100644 --- a/winsup/cygwin/fhandler/console.cc +++ b/winsup/cygwin/fhandler/console.cc @@ -771,6 +771,8 @@ fhandler_console::setup () con.disable_master_thread = true; con.master_thread_suspended = false; con.num_processed = 0; + con.curr_input_mode = tty::restore; + con.curr_output_mode = tty::restore; } } @@ -849,11 +851,6 @@ fhandler_console::set_input_mode (tty::cons_mode m, const termios *t, flags |= ENABLE_PROCESSED_INPUT; break; } - if (con.curr_input_mode != tty::cygwin && m == tty::cygwin) - { - prev_input_mode_backup = con.prev_input_mode; - con.prev_input_mode = oflags; - } con.curr_input_mode = m; SetConsoleMode (p->input_handle, flags); if (!(oflags & ENABLE_VIRTUAL_TERMINAL_INPUT) @@ -893,11 +890,6 @@ fhandler_console::set_output_mode (tty::cons_mode m, const termios *t, flags |= DISABLE_NEWLINE_AUTO_RETURN; break; } - if (con.curr_output_mode != tty::cygwin && m == tty::cygwin) - { - prev_output_mode_backup = con.prev_output_mode; - GetConsoleMode (p->output_handle, &con.prev_output_mode); - } con.curr_output_mode = m; acquire_attach_mutex (mutex_timeout); DWORD resume_pid = attach_console (con.owner); @@ -1845,6 +1837,12 @@ fhandler_console::open (int flags, mode_t) handle_set.output_handle = h; release_output_mutex (); + if (con.owner == GetCurrentProcessId ()) + { + GetConsoleMode (get_handle (), &con.prev_input_mode); + GetConsoleMode (get_output_handle (), &con.prev_output_mode); + } + wpbuf.init (); handle_set.input_mutex = input_mutex; @@ -1890,6 +1888,19 @@ fhandler_console::open (int flags, mode_t) setenv ("TERM", "cygwin", 1); } + if (con.curr_input_mode != tty::cygwin) + { + prev_input_mode_backup = con.prev_input_mode; + GetConsoleMode (get_handle (), &con.prev_input_mode); + set_input_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set); + } + if (con.curr_output_mode != tty::cygwin) + { + prev_output_mode_backup = con.prev_output_mode; + GetConsoleMode (get_output_handle (), &con.prev_output_mode); + set_output_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set); + } + debug_printf ("opened conin$ %p, conout$ %p", get_handle (), get_output_handle ()); @@ -4738,7 +4749,7 @@ fhandler_console::cons_mode_on_close (handle_set_t *p) NTSTATUS status = NtQueryInformationProcess (GetCurrentProcess (), ProcessBasicInformation, &pbi, sizeof (pbi), NULL); - if (NT_SUCCESS (status) + if (NT_SUCCESS (status) && cygwin_pid (con.owner) && !process_alive ((DWORD) pbi.InheritedFromUniqueProcessId)) /* Execed from normal cygwin process and the parent has been exited. */ return tty::cygwin; diff --git a/winsup/cygwin/local_includes/cygtls.h b/winsup/cygwin/local_includes/cygtls.h index 079ada9..4698352 100644 --- a/winsup/cygwin/local_includes/cygtls.h +++ b/winsup/cygwin/local_includes/cygtls.h @@ -229,7 +229,7 @@ public: /* Do NOT remove this public: line, it's a marker for gentls_offsets. */ bool interrupt_now (CONTEXT *, siginfo_t&, void *, struct sigaction&); void interrupt_setup (siginfo_t&, void *, struct sigaction&); - bool inside_kernel (CONTEXT *); + bool inside_kernel (CONTEXT *, bool inside_cygwin = false); void signal_debugger (siginfo_t&); #ifdef CYGTLS_HANDLE diff --git a/winsup/doc/path.xml b/winsup/doc/path.xml index f56614b..9665f6b 100644 --- a/winsup/doc/path.xml +++ b/winsup/doc/path.xml @@ -33,12 +33,12 @@ <refsect1 id="func-cygwin-conv-path-desc"> <title>Description</title> -<para>Use this function to convert POSIX paths in -<parameter>from</parameter> to Win32 paths in <parameter>to</parameter> -or, vice versa, Win32 paths in <parameter>from</parameter> to POSIX paths -in <parameter>to</parameter>. <parameter>what</parameter> -defines the direction of this conversion and can be any of the below -values.</para> +<para>Use this function to convert NUL-terminated POSIX paths in +<parameter>from</parameter> to NUL-terminated Win32 paths in +<parameter>to</parameter> or, vice versa, NUL-terminated Win32 paths in +<parameter>from</parameter> to NUL-terminated POSIX paths in +<parameter>to</parameter>. <parameter>what</parameter> defines the +direction of this conversion and can be any of the below values.</para> <programlisting> CCP_POSIX_TO_WIN_A /* from is char *posix, to is char *win32 */ @@ -62,7 +62,8 @@ default.</para> <para><parameter>size</parameter> is the size of the buffer pointed to by <parameter>to</parameter> in bytes. If <parameter>size</parameter> -is 0, <function>cygwin_conv_path</function> just returns the required +is 0, <parameter>to</parameter> may be NULL and +<function>cygwin_conv_path</function> just returns the required buffer size in bytes. Otherwise, it returns 0 on success, or -1 on error and errno is set to one of the below values.</para> @@ -73,6 +74,12 @@ error and errno is set to one of the below values.</para> of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH. ENOSPC size is less than required for the conversion. </programlisting> + +<para>In the event of an error, the memory at <parameter>to</parameter> is +not modified unless the error is <constant>EFAULT</constant> writing to +the memory at <parameter>to</parameter>, which may happen if +<parameter>size</parameter> is incorrectly specified.</para> + </refsect1> <refsect1 id="func-cygwin-conv-path-example"> diff --git a/winsup/testsuite/stress/cygstress b/winsup/testsuite/stress/cygstress index 9c274ea..55412ef 100755 --- a/winsup/testsuite/stress/cygstress +++ b/winsup/testsuite/stress/cygstress @@ -73,7 +73,7 @@ stress_tests=' chmod # WORKS,CI chown # FAILS # TODO undecided: "fchown failed, errno=22 (Invalid argument)" chroot # admin - clock # WORKS # clock_settime was able to set an invalid negative time for timer 'CLOCK_REALTIME' + clock # WORKS,CI # (fixed in stress-ng 0.18.12: "timer_create failed for timer ... # ... ''CLOCK_THREAD_CPUTIME_ID'', errno=134") clone # ----- close # FAILS # TODO Cygwin: close(2) is not thread-safe |