[Bug libstdc++/90646] std::filesystem::absolute( "yourpathhere" ) segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90646 Andrew Pinski changed: What|Removed |Added Component|c++ |libstdc++ --- Comment #2 from Andrew Pinski --- Can you provide a compilable example?
[Bug libstdc++/90646] std::filesystem::absolute( "yourpathhere" ) segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90646 --- Comment #3 from myLC at gmx dot net --- (In reply to Andrew Pinski from comment #2) > Can you provide a compilable example? Good point. The example works, hence the problem seems to be somewhere else: #include #include #include #include std::optional< std::string > read( const std::filesystem::path &path, const std::string &filename ) { std::string s; if( !filename.empty() ) { std::filesystem::path file( path ); file /= filename; if( std::filesystem::exists( file ) ) { std::ifstream input( std::filesystem::absolute( file ) ); std::stringstream buffer; buffer << input.rdbuf(); if( input.bad() ) goto errout; s = buffer.str(); } } else { errout: return {}; } return s; } int main( int argc, char **argv ) { std::string read_write_test; if( auto rwt = read( "./", argv[ 0 ] ) ) read_write_test = *rwt; if( !read_write_test.empty() ) std::cout << "fine" << std::endl; return 0; } I need to investigate this further...
[Bug libstdc++/90646] std::filesystem::absolute( "yourpathhere" ) segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90646 myLC at gmx dot net changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |WORKSFORME --- Comment #4 from myLC at gmx dot net --- The example works with the same path. The real code is correct, though. I'm guessing this might have something to do with a 3rd-party library corrupting memory, The library needs to be built with the same compiler and options (Nana C++). I need to rebuild that thing and see, if this fixes it. I apologize. I should have created an example first.
[Bug libstdc++/90646] std::filesystem::absolute( "yourpathhere" ) segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90646 --- Comment #5 from Jonathan Wakely --- Is it possible you're mixing code compiled with GCC 8 and GCC 9? In general that works, but not for the new C++17 components that were still experimental in GCC 8, such as filesystem::path. Valgrind might give you more information about the crash, to help debug the problem.
[Bug libstdc++/90646] std::filesystem::absolute( "yourpathhere" ) segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90646 --- Comment #6 from myLC at gmx dot net --- I'm afraid that wasn't it. I rebuilt the Nana (GUI) library with the same compiler (gcc/c++-9.1.0) and I'm still facing the same problem. Valgrind croaked with 'Process finished with exit code 9', which makes sense. The output shows the 'Invalid read of size 8' ( if (__ptr != nullptr) ) in unique_ptr.h: std::unique_ptr::~unique_ptr() std::filesystem::path::_List::~_List() std::filesystem::path::~path() std::filesystem::current_path(std::error_code&) std::filesystem::current_path() std::filesystem::absolute(std::filesystem::path const&) Config::read(std::filesystem::path const&, std::string const&) main Address 0xb is not stack'd, malloc'd or (recently) free'd I'm in for a lot of fun, it seems...
[Bug libstdc++/90646] std::filesystem::absolute( "yourpathhere" ) segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90646 --- Comment #7 from Jonathan Wakely --- It could also be Bug 90557 (which is fixed in the gcc-9-branch but present in the gcc 9.1.0 release) but the symptoms don't look similar.
[Bug libstdc++/90646] std::filesystem::absolute( "yourpathhere" ) segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90646 --- Comment #8 from myLC at gmx dot net --- (In reply to Jonathan Wakely from comment #7) > It could also be Bug 90557 (which is fixed in the gcc-9-branch but present > in the gcc 9.1.0 release) but the symptoms don't look similar. This is possible. I built 9.1.0 from source and got new issues, though. Chances are, my system could be too old. I'm moving back to gcc-8 until I've updated. This feels too much like poking around in the dark.
[Bug libstdc++/90646] std::filesystem::absolute( "yourpathhere" ) segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90646 --- Comment #9 from Jonathan Wakely --- (In reply to myLC from comment #8) > This is possible. I built 9.1.0 from source and got new issues, though. > Chances are, my system could be too old. The std::filesystem code (and everything else in libstdc++) should work fine on old systems, albeit with slightly degraded functionality or less efficient implementations for some features. I'll leave it with you, please feel free to reopen this bug if you do find a problem in GCC.