- Notifications
You must be signed in to change notification settings - Fork 48
[backport] Cygwin: lock cygheap during fork #312
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
Conversation
...so that cygheap can be locked/unlocked from outside of mm/cygheap.cc. Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> (cherry picked from commit aec6dc7)
...completion in child process because the cygheap should not be changed to avoid mismatch between child_info::cygheap_max and ::cygheap_max. Otherwise, child_copy() might copy cygheap being modified by other process. In addition, to avoid deadlock, move close_all_files() for non- Cygwin processes after unlocking cygheap, since close_all_files() calls cfree(), which attempts to lock cygheap even when it's already locked. Fixes: 977ad54 ("* spawn.cc (spawn_guts): Call refresh_cygheap before creating a new process to ensure that cygheap_max is up-to-date.") Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> (cherry picked from commit 9b66723)
another thread may simultaneously be doing a cmalloc/cfree while the cygheap is being copied to the child. Addresses: https://cygwin.com/pipermail/cygwin/2025-September/258801.html Signed-off-by: Jeremy Drake <cygwin@jdrake.com> (cherry picked from commit 8a5d395)
8d67970 to a8c3780 Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and will make rust happier at least. (this won't help the "resource unavailable" fork errors, but will help hangs when building with lots of threads)
| So for the other errors retrying might work (I tried 3 times so far for the msys build)? |
| No I don't think retrying will help, the base addresses are deterministic. I think you'd need to try different paths (I think that's why it succeeded in MSYS2 CI ( |
| Ah, hm, that. I was wondering if we should patch binutils to take a seed from an env var instead (is that binutils??). The python update is also stuck on address conflicts.. |
| Yeah, binutils - circa https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/emultempl/pep.em;h=60a833947bd524d06241d9d54f5999f69594643d;hb=HEAD#l937 for 64-bit (https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/emultempl/pe.em;h=b522687c1d5b4e4fb1d3d998b6ee5f19232b264c;hb=HEAD#l968 for 32-bit). The posix_spawn work I was doing helps with rust, because it uses posix_spawn to call the linker. Those changes result in posix_spawn not using a fork, so it doesn't matter that the dll can't load to the same address. I don't know if python uses posix_spawn or fork/exec directly so I don't know if that would help it. |
| It should in some cases: python/cpython#113118 though cygwin might need |
| no closefrom in cygwin, so not in posix_spawn either |
| Hrm. It seems that this change causes pretty consistent CI failures over in Cygwin: https://github.com/cygwin/cygwin/actions/workflows/cygwin.yml |
| no, it was the switch of windows-latest from 2022 to 2025: cygwin/cygwin@d704d04 |
As suggested here: msys2/MSYS2-packages#5637 (comment)