From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2.protonmail.ch (mail2.protonmail.ch [185.70.40.22]) by sourceware.org (Postfix) with ESMTPS id 311BA383B825 for ; Thu, 8 Jul 2021 05:41:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 311BA383B825 Date: Thu, 08 Jul 2021 05:41:40 +0000 To: "cygwin@cygwin.com" From: Max Mikhanosha Reply-To: Max Mikhanosha Subject: fstream::open crashes if first file it ever opening is in /proc Message-ID: <_022Gh93RaZBX0JIf3f3UuZ7mekqKNi9g4ap-KHKpAa_ppq6O8Y3WXBDUUCw6yK6KJCdfhrFhwGfbB-UZD5R0wmWa2Lo6ZE6glWt4JzyDns=@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2021 05:41:46 -0000 Fully updated Windows 10, with freshly downloaded Cygwin. trying to compile google/benchmark does not work coz it can't read /proc/cp= uinfo Reduced test test program #include #include int main (int argc, char **argv) { if (argc > 1) { std::fstream booya ("whatever"); } std::fstream f("/proc/cpuinfo"); if (!f.is_open ()){ std::cout << "Unable to open /proc/cpuinfo" << std::endl; } return 0; } Repro log user@MARS ~ $ g++ blah.cc user@MARS ~ $ ./a.exe # this does not work Unable to open /proc/cpuinfo user@MARS ~ $ ./a.exe foobar # this works user@MARS ~ $ ldd a.exe ntdll.dll =3D> /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffa5c7900= 00) KERNEL32.DLL =3D> /cygdrive/c/WINDOWS/System32/KERNEL32.DLL (0x7ffa= 5ab20000) KERNELBASE.dll =3D> /cygdrive/c/WINDOWS/System32/KERNELBASE.dll (0x= 7ffa5a000000) cygwin1.dll =3D> /usr/bin/cygwin1.dll (0x180040000) cyggcc_s-seh-1.dll =3D> /usr/bin/cyggcc_s-seh-1.dll (0x3e6ea0000) cygstdc++-6.dll =3D> /usr/bin/cygstdc++-6.dll (0x3be3a0000) user@MARS ~ $ cygcheck -f /usr/bin/cyggcc_s-seh-1.dll /usr/bin/cygstdc++-6.dll /usr/bin= /cygwin1.dll cygwin-3.2.0-1 libgcc1-10.2.0-1 libstdc++6-10.2.0-1 gdb shows that it crashes inside _newlib_flockfile_start(fp) as shown below Thread 1 "a" hit Breakpoint 1, _fopen_r (ptr=3D0xffffd680, file=3D0x10040300a "/proc/cpuinfo", mode= =3D0x3be4a17bb "r+") at /usr/src/debug/cygwin-3.2.0-1/newlib/libc/stdio/fopen.c:119 119 { (gdb) n 124 if ((flags =3D __sflags (ptr, mode, &oflags)) =3D=3D 0) (gdb) n 126 if ((fp =3D __sfp (ptr)) =3D=3D NULL) (gdb) n 129 if ((f =3D _open_r (ptr, file, oflags, 0666)) < 0) (gdb) n 140 _newlib_flockfile_start (fp); (gdb) n 0 [main] a 4876 cygwin_exception::open_stackdumpfile: Dumping stack t= race to a.exe.stackdump [Thread 8800.0x4220 exited with code 35584] [Thread 8800.0x1100 exited with code 35584] [Thread 8800.0x1230 exited with code 35584] [Thread 8800.0x3cc4 exited with code 35584] Googling around found this https://sourceware.org/pipermail/newlib/2015/012= 649.html which gave me idea to try opening normal file first to see if thi= s fixes it, and it does, so likely this patch will fix this problem