From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E3EC33858C39; Thu, 9 Dec 2021 13:25:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3EC33858C39 From: "mathieu.malaterre at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden Date: Thu, 09 Dec 2021 13:25:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mathieu.malaterre at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Dec 2021 13:25:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103629 Bug ID: 103629 Summary: Possible miscompilation triggered by -fvisibility=3Dhidden Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mathieu.malaterre at gmail dot com Target Milestone: --- Executive summary: --- ``` % LD_LIBRARY_PATH=3D./openvdb/openvdb ./openvdb/openvdb/cmd/vdb_view zsh: segmentation fault LD_LIBRARY_PATH=3D./openvdb/openvdb ./openvdb/openvdb/cmd/vdb_view ``` Actual bug description: --- Upon recompilation of openvdb-8.1.0 within a Debian/sid environment, the initialization logic starts to fails and eventually lead to a segfault. Inspection of the gdb backtrace does not pinpoint any obvious mistake: % LD_LIBRARY_PATH=3D./openvdb/openvdb gdb ./openvdb/openvdb/cmd/vdb_view GNU gdb (Debian 10.1-2) 10.1.90.20210103-git Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later 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: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./openvdb/openvdb/cmd/vdb_view... (gdb) r --help Starting program: /home/malat/openvdb-8.1.0/obj-x86_64-linux-gnu/openvdb/openvdb/cmd/vdb_view --help [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff6da0640 (LWP 31308)] [New Thread 0x7ffff659f640 (LWP 31309)] [New Thread 0x7ffff5d9e640 (LWP 31310)] [New Thread 0x7ffff559d640 (LWP 31311)] Thread 1 "vdb_view" received signal SIGSEGV, Segmentation fault. 0x00007ffff78d3228 in std::__cxx11::basic_string, std::allocator >::basic_string(std::__cxx11::basic_string, std::allocator > const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (gdb) bt full #0 0x00007ffff78d3228 in std::__cxx11::basic_string, std::allocator >::basic_string(std::__cxx11::basic_string, std::allocator > const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 No symbol table info available. #1 0x00007ffff7cac65a in openvdb::v8_1::Grid, 4u>, 5u> > > >::gridType[abi:cxx11]() () at /usr/include/c++/11/bits/unique_ptr.h:173 No locals. #2=20 openvdb::v8_1::Grid, 4u>, 5u> > > >::registerGrid () at ./openvdb/openvdb/Grid.h:981 No locals. #3 openvdb::v8_1::initialize () at ./openvdb/openvdb/openvdb.cc:94 lock =3D {_M_device =3D @0x7ffff7fca760} #4 0x0000555555574c40 in main (argc=3D, argv=3D0x7fffffffe4= f8) at ./openvdb/openvdb/cmd/openvdb_view.cc:67 printInfo =3D viewer =3D {} allGrids =3D std::vector of length 1, capacity -2932030871777 =3D {std::shared_ptr (use count 1027951951, weak count 1836017710) =3D {get() =3D 0x7fffffffe720}, std::shared_ptr (use count 1831822= 701, weak count 1952541792) =3D {get() =3D 0x0}, std::shared_ptr (use count 1869361= 010, weak count 795631970) =3D {get() =3D 0x7fffffffe784}, std::shared_ptr (use count 1330792= 515, weak count 1314870350) =3D {get() =3D 0x7fffffffe7b4}, std::shared_ptr (use count 1027885= 383, weak count 808988978) =3D {get() =3D 0x7fffffffe7f1}, std::shared_ptr (use count 1397966= 163, weak count 1598967624) =3D {get() =3D 0x7fffffffe817}, std::shared_ptr (use count 1380275= 029, weak count 1818324284) =3D {get() =3D 0x7fffffffe875}, std::shared_ptr (use count 8418379= 38, weak count 1868772916) =3D {get() =3D 0x7fffffffe899}, std::shared_ptr (use count 1027888= 976, weak count 1836017710) =3D {get() =3D 0x7fffffffe8bc}, std::shared_ptr (use count 1701670= 760, weak count 1818324270) =3D {get() =3D 0x7fffffffe8cf}, std::shared_ptr (use count 1348426= 066, weak count 1028150336) =3D {get() =3D 0x7fffffffe938}, std::shared_ptr (use count 1280262= 912, weak count 1397640532) =3D {get() =3D 0x7fffffffef49}, std::shared_ptr (empty) =3D { get() =3D 0x7fffffffefa0}, std::shared_ptr (expired, weak count 0) =3D {get() =3D 0x21}, , , , std::shared_ptr (use count 64, weak count -1) =3D {get() =3D 0x3}, , , std::shared_ptr (expired, weak count 0) =3D = {get() =3D 0x7}, std::shared_ptr (empty) =3D {get()= =3D 0x8}, std::shared_ptr (use count -461158174, weak count 1280594159) =3D {get() =3D 0x9}, , , , , std::shared_ptr (empty) =3D {get() =3D 0x17}, std::shared_ptr (use count 1418260= 266, weak count 1475371345) =3D {get() =3D 0x19}, std::shared_ptr (empty) =3D {get() =3D 0x1a}, std::shared_ptr (use count 7961562= 68, weak count 1852141678) =3D {get() =3D 0x1f}, std::shared_ptr (use count 1701670= 760, weak count 1818324270) =3D {get() =3D 0xf}, std::shared_ptr (empty) =3D {get() =3D 0x0}, , , [--trimmed--] , indent =3D "" printGLInfo =3D printVersionInfo =3D filenames =3D std::vector of length 4398042310015, capacity 1342177= 27 =3D { numFiles =3D progName =3D 0x7fffffffe763 "vdb_view" status =3D 0 (gdb) Steps: ``` debian-sid $ dget -u http://deb.debian.org/debian/pool/main/o/openvdb/openvdb_8.1.0-3.dsc debian-sid $ cd openvdb-8.1.0 debian-sid $ debuild ``` The above should fails the `help2man` steps which basically simply does: ``` $ cd obj-x86_64-linux-gnu $ LD_LIBRARY_PATH=3D./openvdb/openvdb ./openvdb/openvdb/cmd/vdb_view --help ``` 1. It should be noticed that the openvdb binaries uploaded in Debian bullse= ye (current stable) are working as expected. 2. It should also be noticed that removing of the flag `-fvisibility=3Dhidd= en` makes the symptom go away. As discussed on the gcc-help mailing list, I've been working on reducing the bug to something useful, but failed to. `c-vise` does not seems to produce anything meaningful within two hours timelapse. I've been unable to provide= the necessary time to do a brute-force approach (#ifdef-ing the code), so far. References: * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D997080 * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D1001136 % gcc --version gcc (Debian 11.2.0-12) 11.2.0 % apt-cache policy libtbb2 libtbb2: Installed: 2020.3-1 Candidate: 2020.3-1 Version table: *** 2020.3-1 500 % /lib/x86_64-linux-gnu/libc.so.6 GNU C Library (Debian GLIBC 2.32-5) stable release version 2.32. Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 10.3.1 20211117. libc ABIs: UNIQUE IFUNC ABSOLUTE For bug reporting instructions, please see: .=