[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled

igorlord at alum dot mit.edu gcc-bugzilla@gcc.gnu.org
Tue May 20 22:45:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984

--- Comment #4 from Igor <igorlord at alum dot mit.edu> ---
This is a really evil bug.  I wonder why the Importance is not higher.

This may crash programs that try to read many /proc files on Linux.


~$ g++ -x c++ -o test - <<EOF
#include <fstream>
#include <unistd.h>
int main(int argc, char *argv[])
{
    std::ifstream in(argv[1]);
    sleep(4);
    std::string s;
    if (in)
      in >> s;
    return 0;
}
EOF

~$ sleep 2 & ./test "/proc/${!}/stat"

terminate called after throwing an instance of 'std::ios_base::failure'
  what():  basic_filebuf::underflow error reading the file
Aborted (core dumped)



More information about the Gcc-bugs mailing list