Segfault if /proc/PID/maps is opened in parallel threads [CAUSE: RtlQueryProcessDebugInformation]
Christian Franke
Christian.Franke@t-online.de
Tue May 27 15:44:10 GMT 2025
On Sun, 25 May 2025 16:46:49 +0200, Christian Franke wrote:
> On Sat, 24 May 2025 15:19:10 +0200, Christian Franke wrote:
>> If /proc/PID/maps is opened in parallel threads, the process PID may
>> segfault.
>>
>> Testcase:
>>
>> ...
>>
>> Problem is not reproducible with any of the other /proc/PID/* files.
>>
>
> A closer look shows that the problem is unrelated to thread safety.
> The segfault also occurs when the following command is run
> simultaneously in two terminals:
>
> $ while cat /proc/1234/maps > /dev/null; do printf .; done
> .............cat: /proc/1234/maps: No such file or directory
>
The root of the problem is the call of RtlQueryProcessDebugInformation()
here:
https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/fhandler/process.cc;h=8fae9be5#l630
If this part is removed, the segfault does no longer occur. Then
/proc/PID/maps still work but the "[win heap ...]" information is
missing. No patch provided because I don't know whether this could
possibly be fixed without removing this functionality.
A test with a separate test program shows that the problem is unrelated
to Cygwin: Parallel calls to RtlQueryProcessDebugInformation() with the
same PID could be used to crash this process. It also "worked" with
Notepad.exe.
Possible Windows (Version 10.0.22631.5039) bug?
--
Regards,
Christian
More information about the Cygwin
mailing list