New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loop: better align order-of-events behavior between platforms #3598
Conversation
Previously, Windows would always defer event processing to the loop after they were received. This could cause confusion for users who were using prepare and idle callbacks, as seen from this bug in nodejs[^1] and this discussion in libuv[^2], and even some discrepancies in the libuv tests too[^3]. [^1]: nodejs/node#42340 [^2]: libuv#3550 [^3]: See change to test-spawn.c in this PR So rather than declare those usages to be wrong, we change libuv to meet those users expectations. Replaces: libuv#3585
This patch should hopefully fix the node build errors: diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp
index 093f611fb6f..a3e9819a7e0 100644
--- a/deps/uv/uv.gyp
+++ b/deps/uv/uv.gyp
@@ -78,6 +78,8 @@
'src/random.c',
'src/strscpy.c',
'src/strscpy.h',
+ 'src/strtok.c',
+ 'src/strtok.h',
'src/threadpool.c',
'src/timer.c',
'src/uv-data-getter-setters.c', |
https://ci.nodejs.org/view/libuv/job/libuv-in-node/212/ - this PR with gyp patch applied |
The shared library build timed out (not our fault) and the osx-arm failure is known flake nodejs/node#42741 but the Windows failures might be related. |
this seems somewhat concerning and needs to be investigated
From a quick glance, this looks like it might be calling the 'destroy' handle with a setImmediate callback, and somehow the timing of that is changing here. I am not sure yet whether that is a bad assumption with nodejs or an issue being caused here. The rest look likely to be nodejs bugs (some already known and in the process of being fixed). This looks fairly suspect, since it seems that the client code is doing a big upload, then is depending on |
The TCPWRAP failure seems related to nodejs/node#17117, which appears to define that uv_check_t handles must be run in some particular way and order relative to some other events, such that the callback from that |
If `uv_close` was called while a connect was pending, we would fail to release the resources for the connection, since we had not yet set the type of the struct. Fix a thread data-race on slow connect path code: only permitted to write to `req` on threads, as anything else causes data race corruption. There seemed be a small variety of other resource management bugs in edge cases, which turned out to make this a lot larger than initially expected. Refs: #3598 (comment)
If `uv_close` was called while a connect was pending, we would fail to release the resources for the connection, since we had not yet set the type of the struct. Fix a thread data-race on slow connect path code: only permitted to write to `req` on threads, as anything else causes data race corruption. There seemed be a small variety of other resource management bugs in edge cases, which turned out to make this a lot larger than initially expected. Refs: libuv#3598 (comment)
…3598) Previously, Windows would always defer event processing to the loop after they were received. This could cause confusion for users who were using prepare and idle callbacks, as seen from this bug in nodejs[^1] and this discussion in libuv[^2], and even some discrepancies in the libuv tests too[^3]. [^1]: nodejs/node#42340 [^2]: libuv#3550 [^3]: See change to test-spawn.c in this PR So rather than declare those usages to be wrong, we change libuv to meet those users expectations. Replaces: libuv#3585
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: #42290 PR-URL: #42340 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: nodejs#42290 PR-URL: nodejs#42340 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: #42290 PR-URL: #42340 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: #42290 PR-URL: #42340 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: #42290 PR-URL: #42340 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Notable changes: - Build regression fixes for various platform updates (libuv/libuv#3428, libuv/libuv#3419, libuv/libuv#3423, libuv/libuv#3413, libuv/libuv#3431) - Support for GNU/Hurd (libuv/libuv#3450) - Release tool improvements (libuv/libuv-release-tool#13) - Better performing rw locks on Win32 (libuv/libuv#3383) - Support for posix_spawn API (libuv/libuv#3257) - Fix regression on OpenBSD (libuv/libuv#3506) - Add uv_available_parallelism() (libuv/libuv#3499) - Don't use thread-unsafe strtok() (libuv/libuv#3524) - Fix hang after NOTE_EXIT (libuv/libuv#3521) - Better align order-of-events behavior between platforms (libuv/libuv#3598) - Fix fs event not fired if the watched file is moved/removed/recreated (libuv/libuv#3540) - Fix pipe resource leak if closed during connect (and other bugs) (libuv/libuv#3611) - Don't error when killing a zombie process (libuv/libuv#3625) - Avoid posix_spawnp() cwd bug (libuv/libuv#3597) - Skip EVFILT_PROC events when invalidating events for an fd (libuv/libuv#3629) Fixes: #42290 PR-URL: #42340 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Previously, Windows would always defer event processing to the loop
after they were received. This could cause confusion for users who were
using prepare and idle callbacks, as seen from this bug in nodejs1 and
this discussion in libuv2, and even some discrepancies in the libuv
tests too3.
So rather than declare those usages to be wrong, we change libuv to meet
those users expectations.
Replaces: #3585
Footnotes
https://github.com/nodejs/node/pull/42340 ↩
https://github.com/libuv/libuv/discussions/3550 ↩
See change to test-spawn.c in this PR ↩