From: Max Mikhanosha <max.mikhanosha@protonmail.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: fstream::open crashes if first file it ever opening is in /proc
Date: Thu, 08 Jul 2021 05:41:40 +0000 [thread overview]
Message-ID: <_022Gh93RaZBX0JIf3f3UuZ7mekqKNi9g4ap-KHKpAa_ppq6O8Y3WXBDUUCw6yK6KJCdfhrFhwGfbB-UZD5R0wmWa2Lo6ZE6glWt4JzyDns=@protonmail.com> (raw)
Fully updated Windows 10, with freshly downloaded Cygwin.
trying to compile google/benchmark does not work coz it can't read /proc/cpuinfo
Reduced test test program
#include <iostream>
#include <fstream>
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 => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffa5c790000)
KERNEL32.DLL => /cygdrive/c/WINDOWS/System32/KERNEL32.DLL (0x7ffa5ab20000)
KERNELBASE.dll => /cygdrive/c/WINDOWS/System32/KERNELBASE.dll (0x7ffa5a000000)
cygwin1.dll => /usr/bin/cygwin1.dll (0x180040000)
cyggcc_s-seh-1.dll => /usr/bin/cyggcc_s-seh-1.dll (0x3e6ea0000)
cygstdc++-6.dll => /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=0xffffd680,
file=0x10040300a <std::piecewise_construct+10> "/proc/cpuinfo", mode=0x3be4a17bb "r+")
at /usr/src/debug/cygwin-3.2.0-1/newlib/libc/stdio/fopen.c:119
119 {
(gdb) n
124 if ((flags = __sflags (ptr, mode, &oflags)) == 0)
(gdb) n
126 if ((fp = __sfp (ptr)) == NULL)
(gdb) n
129 if ((f = _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 trace 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/012649.html which gave me idea to try opening normal file first to see if this fixes it, and it does, so likely this patch will fix this problem
next reply other threads:[~2021-07-08 5:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-08 5:41 Max Mikhanosha [this message]
2021-07-08 8:53 ` Csaba Raduly
2021-07-08 14:42 ` Max Mikhanosha
2021-07-09 9:08 ` Csaba Raduly
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='_022Gh93RaZBX0JIf3f3UuZ7mekqKNi9g4ap-KHKpAa_ppq6O8Y3WXBDUUCw6yK6KJCdfhrFhwGfbB-UZD5R0wmWa2Lo6ZE6glWt4JzyDns=@protonmail.com' \
--to=max.mikhanosha@protonmail.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).