[Bug 1824721] Re: g++-8 in disco is broken with libstdc++6 from gcc9 and libstdc++fs

Bug Watch Updater 1824721 at bugs.launchpad.net
Wed Apr 17 02:33:07 UTC 2019


Launchpad has imported 8 comments from the remote bug at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050.

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at
https://help.launchpad.net/InterBugTracking.

------------------------------------------------------------------------
On 2019-04-11T14:11:43+00:00 Mpreda wrote:

#include <filesystem>

int main() {
  std::filesystem::path p = "foo";
}

g++ -g --std=c++17 path.cpp

./a.out 
Segmentation fault (core dumped)

g++ --version
g++ (Ubuntu 8.3.0-6ubuntu1) 8.3.0

uname -a
Linux x2 5.0.6-050006-generic #201904030534 SMP Wed Apr 3 05:36:14 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Ubuntu 19.04.

Core was generated by `./a.out'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055c2ac25149b in std::vector<std::filesystem::__cxx11::path::_Cmpt, std::allocator<std::filesystem::__cxx11::path::_Cmpt> >::~vector (this=0x23, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/stl_vector.h:567
567		std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
(gdb) bt
#0  0x000055c2ac25149b in std::vector<std::filesystem::__cxx11::path::_Cmpt, std::allocator<std::filesystem::__cxx11::path::_Cmpt> >::~vector (this=0x23, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/stl_vector.h:567
#1  0x000055c2ac251314 in std::filesystem::__cxx11::path::~path (this=0x3, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/fs_path.h:208
#2  0x000055c2ac251f5c in std::filesystem::__cxx11::path::_Cmpt::~_Cmpt (this=0x3, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/fs_path.h:643
#3  0x000055c2ac251f77 in std::_Destroy<std::filesystem::__cxx11::path::_Cmpt> (__pointer=0x3) at /usr/include/c++/8/bits/stl_construct.h:98
#4  0x000055c2ac251e27 in std::_Destroy_aux<false>::__destroy<std::filesystem::__cxx11::path::_Cmpt*> (__first=0x3, __last=0x0) at /usr/include/c++/8/bits/stl_construct.h:108
#5  0x000055c2ac251a98 in std::_Destroy<std::filesystem::__cxx11::path::_Cmpt*> (__first=0x3, __last=0x0) at /usr/include/c++/8/bits/stl_construct.h:137
#6  0x000055c2ac2517a9 in std::_Destroy<std::filesystem::__cxx11::path::_Cmpt*, std::filesystem::__cxx11::path::_Cmpt> (__first=0x3, __last=0x0) at /usr/include/c++/8/bits/stl_construct.h:206
#7  0x000055c2ac2514b1 in std::vector<std::filesystem::__cxx11::path::_Cmpt, std::allocator<std::filesystem::__cxx11::path::_Cmpt> >::~vector (this=0x7ffe3ad201d0, __in_chrg=<optimized out>)
    at /usr/include/c++/8/bits/stl_vector.h:567
#8  0x000055c2ac251314 in std::filesystem::__cxx11::path::~path (this=0x7ffe3ad201b0, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/fs_path.h:208
#9  0x000055c2ac251230 in main () at path.cpp:4

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-8/+bug/1824721/comments/0

------------------------------------------------------------------------
On 2019-04-12T10:50:39+00:00 Mpreda wrote:

I would hope somebody would take a look and reject this issues as
invalid for some reason, because otherwise it's rather severe.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-8/+bug/1824721/comments/1

------------------------------------------------------------------------
On 2019-04-13T07:12:50+00:00 Mpreda wrote:

Adding -lstdc++fs fixes the problem with g++ 8.3

g++-9 does not segfault even without -lstdc++fs

g++-9 --version
g++-9 (Ubuntu 9-20190402-1ubuntu1) 9.0.1 20190402 (experimental) [trunk revision 270074]

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-8/+bug/1824721/comments/2

------------------------------------------------------------------------
On 2019-04-13T08:10:35+00:00 Ufospoke wrote:

I just tried with g++ (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2) on Fedora
and it works well. But to be able to link, I had to add -lstdc++fs.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-8/+bug/1824721/comments/3

------------------------------------------------------------------------
On 2019-04-16T10:20:33+00:00 Redi wrote:

The -lstdc++fs requirement for std::filesystem in GCC 8 is documented in
several places:

https://gcc.gnu.org/onlinedocs/gcc-8.3.0/libstdc++/manual/manual/using.html#manual.intro.using.flags
https://gcc.gnu.org/onlinedocs/gcc-8.3.0/libstdc++/manual/manual/status.html#status.iso.2017
https://gcc.gnu.org/onlinedocs/gcc-8.3.0/libstdc++/manual/manual/using_dynamic_or_shared.html#manual.intro.using.linkage.experimental

I don't know why it crashes with Ubuntu, it should be a linker error. I
suspect Ubuntu is doing something silly like providing libstdc++.so from
GCC 9, which defines std::filesystem::path differently, and so is not
compatible with C++17 code compiled using GCC 8.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-8/+bug/1824721/comments/9

------------------------------------------------------------------------
On 2019-04-16T10:22:18+00:00 Redi wrote:

Although if you link with -lstdc++fs then it should work OK, because the
incompatible std::filesystem symbols in libstdc++.so.6.0.26 won't be
used.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-8/+bug/1824721/comments/10

------------------------------------------------------------------------
On 2019-04-16T12:55:08+00:00 Mpreda wrote:

OK, thanks.

So if on Ubuntu 19.04, the default compiler produces without
errors/warnings, from valid source code, an executable that crashes,
that's programmer error?!

I understand the explanation, but there is a problem. Maybe the bug is
not with gcc but with Ubuntu, but a bug there is.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-8/+bug/1824721/comments/14

------------------------------------------------------------------------
On 2019-04-16T13:18:43+00:00 Redi wrote:

See https://bugs.launchpad.net/ubuntu/+source/gcc-8/+bug/1824721 where I
said:

"for now the short answer is "C++17 support in GCC 8 is experimental,
the onus is on you to link correctly"

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-8/+bug/1824721/comments/15


** Changed in: gcc
       Status: Unknown => Invalid

** Changed in: gcc
   Importance: Unknown => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-8 in Ubuntu.
https://bugs.launchpad.net/bugs/1824721

Title:
  g++-8 in disco is broken with libstdc++6 from gcc9 and libstdc++fs

Status in gcc:
  Invalid
Status in gcc-8 package in Ubuntu:
  Incomplete

Bug description:
  There is a significant incompatibility here which leaves the default
  C++ compiler broken with C++17 std::filesystem usage.  Unfortunately,
  there isn't an obvious workaround since there's only one libstdc++6
  package, and it's using the non-default and unreleased GCC9 version of
  libstdc++, making it impossible to use the compatible GCC8 version of
  the library.

  % cat testpath.cpp
  #include <filesystem>

  int main()
  {
    std::filesystem::path p("test");
  }

  g++-9 -std=c++17 -lstdc++fs -g3 -o testpath testpath.cpp 
  % ./testpath

  % g++-8 -std=c++17 -lstdc++fs -g3 -o testpath testpath.cpp
  % ./testpath                                              
  zsh: segmentation fault (core dumped)  ./testpath

  % gdb testpath
  GNU gdb (Ubuntu 8.2.91.20190405-0ubuntu3) 8.2.91.20190405-git
  Copyright (C) 2019 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.
  Type "show copying" and "show warranty" for details.
  This GDB was configured as "x86_64-linux-gnu".
  Type "show configuration" for configuration details.
  For bug reporting instructions, please see:
  <http://www.gnu.org/software/gdb/bugs/>.
  Find the GDB manual and other documentation resources online at:
      <http://www.gnu.org/software/gdb/documentation/>.

  For help, type "help".
  Type "apropos word" to search for commands related to "word"...
  Reading symbols from testpath...
  (gdb) run
  Starting program: /tmp/testpath 

  Program received signal SIGSEGV, Segmentation fault.
  0x000055555555649b in std::vector<std::filesystem::__cxx11::path::_Cmpt, std::allocator<std::filesystem::__cxx11::path::_Cmpt> >::~vector (this=0x23, __in_chrg=<optimised out>) at /usr/include/c++/8/bits/stl_vector.h:567
  567             std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
  (gdb) bt
  #0  0x000055555555649b in std::vector<std::filesystem::__cxx11::path::_Cmpt, std::allocator<std::filesystem::__cxx11::path::_Cmpt> >::~vector (this=0x23, __in_chrg=<optimised out>) at /usr/include/c++/8/bits/stl_vector.h:567
  #1  0x0000555555556314 in std::filesystem::__cxx11::path::~path (this=0x3, __in_chrg=<optimised out>)
      at /usr/include/c++/8/bits/fs_path.h:208
  #2  0x0000555555556f5c in std::filesystem::__cxx11::path::_Cmpt::~_Cmpt (this=0x3, __in_chrg=<optimised out>)
      at /usr/include/c++/8/bits/fs_path.h:643
  #3  0x0000555555556f77 in std::_Destroy<std::filesystem::__cxx11::path::_Cmpt> (__pointer=0x3)
      at /usr/include/c++/8/bits/stl_construct.h:98
  #4  0x0000555555556e27 in std::_Destroy_aux<false>::__destroy<std::filesystem::__cxx11::path::_Cmpt*> (
      __first=0x3, __last=0x0) at /usr/include/c++/8/bits/stl_construct.h:108
  #5  0x0000555555556a98 in std::_Destroy<std::filesystem::__cxx11::path::_Cmpt*> (__first=0x3, __last=0x0)
      at /usr/include/c++/8/bits/stl_construct.h:137
  #6  0x00005555555567a9 in std::_Destroy<std::filesystem::__cxx11::path::_Cmpt*, std::filesystem::__cxx11::path::_Cmpt> (__first=0x3, __last=0x0) at /usr/include/c++/8/bits/stl_construct.h:206
  #7  0x00005555555564b1 in std::vector<std::filesystem::__cxx11::path::_Cmpt, std::allocator<std::filesystem::__cxx11::path::_Cmpt> >::~vector (this=0x7fffffffe310, __in_chrg=<optimised out>)
      at /usr/include/c++/8/bits/stl_vector.h:567
  #8  0x0000555555556314 in std::filesystem::__cxx11::path::~path (this=0x7fffffffe2f0, __in_chrg=<optimised out>)
      at /usr/include/c++/8/bits/fs_path.h:208
  #9  0x0000555555556230 in main () at testpath.cpp:5
  (gdb) quit
  A debugging session is active.

          Inferior 1 [process 2414] will be killed.

  Quit anyway? (y or n) y

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1824721/+subscriptions



More information about the foundations-bugs mailing list