* [Bug c++/103629] Possible miscompilation triggered by -fvisibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
@ 2021-12-09 13:30 ` marxin at gcc dot gnu.org
2021-12-09 13:32 ` pinskia at gcc dot gnu.org
` (26 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-09 13:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
> 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
Would it be possible reproducing the issue with the build from source? The
instructions seem to be very Debian-specific.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug c++/103629] Possible miscompilation triggered by -fvisibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
2021-12-09 13:30 ` [Bug c++/103629] " marxin at gcc dot gnu.org
@ 2021-12-09 13:32 ` pinskia at gcc dot gnu.org
2021-12-09 13:38 ` mathieu.malaterre at gmail dot com
` (25 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-09 13:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-fvisibility=hidden hides typeinfo so it could be possibility of having two
typeinfo for the same class in if not used correctly.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug c++/103629] Possible miscompilation triggered by -fvisibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
2021-12-09 13:30 ` [Bug c++/103629] " marxin at gcc dot gnu.org
2021-12-09 13:32 ` pinskia at gcc dot gnu.org
@ 2021-12-09 13:38 ` mathieu.malaterre at gmail dot com
2021-12-09 13:45 ` pinskia at gcc dot gnu.org
` (24 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2021-12-09 13:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #3 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
Steps to reproduce without a full Debian environement:
```
$ wget
http://deb.debian.org/debian/pool/main/o/openvdb/openvdb_8.1.0.orig.tar.xz
$ tar xf openvdb_8.1.0.orig.tar.xz
$ cd openvdb-8.1.0
$ mkdir build
$ cd build
$ export CXXFLAGS=-fvisibility=hidden
$ cmake .. -DOPENVDB_BUILD_VDB_VIEW:BOOL=ON
$ make -j8 vdb_view
$ LD_LIBRARY_PATH=./openvdb/openvdb ./openvdb/openvdb/cmd/vdb_view
```
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug c++/103629] Possible miscompilation triggered by -fvisibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (2 preceding siblings ...)
2021-12-09 13:38 ` mathieu.malaterre at gmail dot com
@ 2021-12-09 13:45 ` pinskia at gcc dot gnu.org
2021-12-09 14:03 ` mathieu.malaterre at gmail dot com
` (23 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-09 13:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Mathieu Malaterre from comment #3)
> $ export CXXFLAGS=-fvisibility=hidden
Yes you can't just use -fvisibility=hidden without the source being ready for
it.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug c++/103629] Possible miscompilation triggered by -fvisibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (3 preceding siblings ...)
2021-12-09 13:45 ` pinskia at gcc dot gnu.org
@ 2021-12-09 14:03 ` mathieu.malaterre at gmail dot com
2021-12-09 14:15 ` pinskia at gcc dot gnu.org
` (22 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2021-12-09 14:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #5 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
(In reply to Andrew Pinski from comment #4)
> (In reply to Mathieu Malaterre from comment #3)
> > $ export CXXFLAGS=-fvisibility=hidden
>
> Yes you can't just use -fvisibility=hidden without the source being ready
> for it.
Andrew, could you please be a bit more specific. I do not see any changes
related to duplicate `typeinfo` or `visibility=hidden` in the changelog:
* https://gcc.gnu.org/gcc-11/changes.html
`-fvisibility=hidden` was added in 2015 in the Debian/OpenVDB package and has
worked quite well for all users so far. It would be nice if gcc/ld would help
track any `type_info` issue, in large portable c++ codebase.
*
https://salsa.debian.org/multimedia-team/openvdb/-/blob/debian/3.0.0-1/debian/rules#L14-15
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug c++/103629] Possible miscompilation triggered by -fvisibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (4 preceding siblings ...)
2021-12-09 14:03 ` mathieu.malaterre at gmail dot com
@ 2021-12-09 14:15 ` pinskia at gcc dot gnu.org
2021-12-09 14:23 ` mathieu.malaterre at gmail dot com
` (21 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-09 14:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Mathieu Malaterre from comment #5)
> (In reply to Andrew Pinski from comment #4)
> > (In reply to Mathieu Malaterre from comment #3)
> > > $ export CXXFLAGS=-fvisibility=hidden
> >
> > Yes you can't just use -fvisibility=hidden without the source being ready
> > for it.
>
> Andrew, could you please be a bit more specific. I do not see any changes
> related to duplicate `typeinfo` or `visibility=hidden` in the changelog:
>
> * https://gcc.gnu.org/gcc-11/changes.html
right there has been no major changes in this area as far as I Know.
>
> `-fvisibility=hidden` was added in 2015 in the Debian/OpenVDB package and
> has worked quite well for all users so far. It would be nice if gcc/ld would
> help track any `type_info` issue, in large portable c++ codebase.
It was working by accident before. Do you know why it was added? Has the code
upstream in OpenVDB been fixed for adding the visibility attribute where
needed?
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug c++/103629] Possible miscompilation triggered by -fvisibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (5 preceding siblings ...)
2021-12-09 14:15 ` pinskia at gcc dot gnu.org
@ 2021-12-09 14:23 ` mathieu.malaterre at gmail dot com
2021-12-10 13:11 ` mathieu.malaterre at gmail dot com
` (20 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2021-12-09 14:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #7 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
(In reply to Andrew Pinski from comment #6)
> (In reply to Mathieu Malaterre from comment #5)
> > (In reply to Andrew Pinski from comment #4)
> > > (In reply to Mathieu Malaterre from comment #3)
> > > > $ export CXXFLAGS=-fvisibility=hidden
> > >
> > > Yes you can't just use -fvisibility=hidden without the source being ready
> > > for it.
> >
> > Andrew, could you please be a bit more specific. I do not see any changes
> > related to duplicate `typeinfo` or `visibility=hidden` in the changelog:
> >
> > * https://gcc.gnu.org/gcc-11/changes.html
>
> right there has been no major changes in this area as far as I Know.
>
> >
> > `-fvisibility=hidden` was added in 2015 in the Debian/OpenVDB package and
> > has worked quite well for all users so far. It would be nice if gcc/ld would
> > help track any `type_info` issue, in large portable c++ codebase.
>
> It was working by accident before. Do you know why it was added? Has the
> code upstream in OpenVDB been fixed for adding the visibility attribute
> where needed?
OpenVDB is supposed to be /portable/ c++. The dll export mechanism has been
working on windows arch since basically day-one.
The gcc implementation is at:
*
https://github.com/AcademySoftwareFoundation/openvdb/blob/master/openvdb/openvdb/Platform.h#L218-L219
IMHO this is following the wiki from:
* https://gcc.gnu.org/wiki/Visibility
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug c++/103629] Possible miscompilation triggered by -fvisibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (6 preceding siblings ...)
2021-12-09 14:23 ` mathieu.malaterre at gmail dot com
@ 2021-12-10 13:11 ` mathieu.malaterre at gmail dot com
2021-12-10 13:13 ` [Bug c++/103629] Possible miscompilation triggered by pthread + exception mathieu.malaterre at gmail dot com
` (19 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2021-12-10 13:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #8 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
% more CMakeLists.txt main.cc Module.cc openvdb.cc Tree.h
::::::::::::::
CMakeLists.txt
::::::::::::::
cmake_minimum_required(VERSION 3.13)
project(p)
# only export limited set of symbols
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
# important to have pthread at runtime:
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
# important to use SHARED:
add_library(openvdb SHARED openvdb.cc)
target_include_directories(openvdb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(vdb_view main.cc Module.cc)
target_link_libraries(vdb_view openvdb Threads::Threads)
target_include_directories(vdb_view PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
::::::::::::::
main.cc
::::::::::::::
void initialize();
int main(int , char *[])
{
initialize();
return 0;
}
::::::::::::::
Module.cc
::::::::::::::
#include "Tree.h"
class Module
{
void init();
};
void Module::init() // no-inline
{
Tree::treeType();
}
::::::::::::::
openvdb.cc
::::::::::::::
#include "Tree.h"
static std::string do_segfault() { return Tree::treeType(); }
__attribute__((visibility("default")))
void initialize()
{
do_segfault();
}
::::::::::::::
Tree.h
::::::::::::::
#pragma once
#include <mutex>
#include <memory>
class Tree
{
public:
static const std::string treeType() {
static std::once_flag once;
std::call_once(once, []() {
sTreeTypeName.reset(new std::string());
});
return *sTreeTypeName;
}
private:
static std::unique_ptr<const std::string> sTreeTypeName;
};
std::unique_ptr<const std::string> Tree::sTreeTypeName;
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug c++/103629] Possible miscompilation triggered by pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (7 preceding siblings ...)
2021-12-10 13:11 ` mathieu.malaterre at gmail dot com
@ 2021-12-10 13:13 ` mathieu.malaterre at gmail dot com
2021-12-10 13:20 ` [Bug c++/103629] Possible miscompilation visible using " pinskia at gcc dot gnu.org
` (18 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2021-12-10 13:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #9 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
Compiling the reduce test case without pthread lead to some kind of exception:
```
(gdb) bt full
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
set = {__val = {0 <repeats 12 times>, 8245935278387129975,
5908832823118463008, 0, 0}}
pid = <optimized out>
tid = <optimized out>
ret = <optimized out>
#1 0x00007ffff7bf9536 in __GI_abort () at abort.c:79
save_stage = 1
act = {__sigaction_handler = {sa_handler = 0x7ffff7d925e0
<_IO_2_1_stderr_>, sa_sigaction = 0x7ffff7d925e0 <_IO_2_1_stderr_>}, sa_mask =
{__val = {140737350282933, 140737351591392, 140737351591392,
140737351591523, 140737351595200, 3432, 140737350279750, 11, 1,
140737351591392, 93824992325712, 140737352586656, 140737488347968, 0,
140737350287193, 140737351591840}}, sa_flags = -135945484,
sa_restorer = 0x7ffff7d927a0 <stderr>}
sigs = {__val = {32, 0, 0, 0, 17, 9223372036854775922, 140737352422480,
140737350282933, 0, 140737350282933, 140737353353159, 140737351591392,
93824992325672, 140737351595200, 3432, 140737350279750}}
#2 0x00007ffff7e4f87a in __gnu_cxx::__verbose_terminate_handler () at
../../../../src/libstdc++-v3/libsupc++/vterminate.cc:95
terminating = true
t = <optimized out>
#3 0x00007ffff7e5b04a in __cxxabiv1::__terminate (handler=<optimized out>) at
../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:48
No locals.
#4 0x00007ffff7e5b0b5 in std::terminate () at
../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:58
No locals.
#5 0x00007ffff7e5b349 in __cxxabiv1::__cxa_throw (obj=<optimized out>,
tinfo=0x7ffff7fb1530 <typeinfo for std::system_error>, dest=0x7ffff7e855a0
<std::system_error::~system_error()>)
at ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc:95
globals = <optimized out>
header = 0x55555556aeb0
#6 0x00007ffff7e525fa in std::__throw_system_error(int) () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#7 0x00007ffff7fc740f in
std::call_once<Tree::treeType()::{lambda()#1}>(std::once_flag&,
Tree::treeType()::{lambda()#1}&&) (__once=..., __f=...) at
/usr/include/c++/11/mutex:784
__e = -1
__callable = {____f = @0x7fffffffe3ff}
__exec = {<No data fields>}
```
I am not able to reproduce gcc behavior using clang++ (again Debian sid
version).
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug c++/103629] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (8 preceding siblings ...)
2021-12-10 13:13 ` [Bug c++/103629] Possible miscompilation triggered by pthread + exception mathieu.malaterre at gmail dot com
@ 2021-12-10 13:20 ` pinskia at gcc dot gnu.org
2021-12-10 13:22 ` [Bug libstdc++/103629] " pinskia at gcc dot gnu.org
` (17 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-10 13:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |---
Status|RESOLVED |UNCONFIRMED
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this is solved on the trunk. The issue is not with visibility hidden
but rather with the newer glibc.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (9 preceding siblings ...)
2021-12-10 13:20 ` [Bug c++/103629] Possible miscompilation visible using " pinskia at gcc dot gnu.org
@ 2021-12-10 13:22 ` pinskia at gcc dot gnu.org
2021-12-10 14:33 ` redi at gcc dot gnu.org
` (16 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-10 13:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Plus please don't use cmake and just make a simple makefile for testcases like
this cnake brings in a lot of crap for no reason.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (10 preceding siblings ...)
2021-12-10 13:22 ` [Bug libstdc++/103629] " pinskia at gcc dot gnu.org
@ 2021-12-10 14:33 ` redi at gcc dot gnu.org
2021-12-10 15:01 ` redi at gcc dot gnu.org
` (15 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-10 14:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Simple makefile for comment 8:
CXXFLAGS := -fvisibility=hidden -fvisibility-inlines-hidden
vdb_view: main.o Module.o libopenvdb.so
$(CXX) -o $@ $^ -pthread '-Wl,-rpath,$$ORIGIN'
libopenvdb.so: openvdb.cc
$(CXX) $(CXXFLAGS) -fPIC -shared -Wl,-soname,libopenvdb.so -o $@ $<
clean:
rm -f main.o Module.o libopenvdb.so
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (11 preceding siblings ...)
2021-12-10 14:33 ` redi at gcc dot gnu.org
@ 2021-12-10 15:01 ` redi at gcc dot gnu.org
2021-12-10 15:09 ` redi at gcc dot gnu.org
` (14 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-10 15:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Inside the lambda run by std::call_once, the address of sTreeTypeName is
0x404098, but after std::call_once finishes, the address of the object being
dereferenced is 0x7ffff7fc2090
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (12 preceding siblings ...)
2021-12-10 15:01 ` redi at gcc dot gnu.org
@ 2021-12-10 15:09 ` redi at gcc dot gnu.org
2021-12-10 15:10 ` redi at gcc dot gnu.org
` (13 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-10 15:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> ---
So one copy of that variable gets initialized, and a different copy gets
dereferenced, so it dereferences null.
If you change Tree.h to:
#pragma once
#include <mutex>
#include <memory>
#include <cstdio>
class Tree
{
public:
static const std::string treeType() {
static std::once_flag once;
std::call_once(once, []() {
std::printf("%p\n", &sTreeTypeName);
sTreeTypeName.reset(new std::string());
});
std::printf("%p\n", &sTreeTypeName);
if (!sTreeTypeName)
throw "uhoh";
return *sTreeTypeName;
}
private:
static std::unique_ptr<const std::string> sTreeTypeName;
};
std::unique_ptr<const std::string> Tree::sTreeTypeName;
The program prints:
0x4040b0
0x7f81066af0a8
terminate called after throwing an instance of 'char const*'
Aborted (core dumped)
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (13 preceding siblings ...)
2021-12-10 15:09 ` redi at gcc dot gnu.org
@ 2021-12-10 15:10 ` redi at gcc dot gnu.org
2021-12-10 15:13 ` redi at gcc dot gnu.org
` (12 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-10 15:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #12)
> Simple makefile for comment 8:
A better one:
CXXFLAGS := -fvisibility=hidden -fvisibility-inlines-hidden -g
LDFLAGS := '-Wl,-rpath,$$ORIGIN' -pthread -L.
LDLIBS := -lopenvdb
OBJS := main.o Module.o
LIB := libopenvdb.so
vdb_view: $(OBJS) $(LIB)
$(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS)
Module.o: Tree.h
$(LIB): openvdb.cc Tree.h
$(CXX) $(CXXFLAGS) -fPIC -shared -Wl,-soname,$@ -o $@ $<
clean:
rm -f $(OBJS) $(LIB)
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (14 preceding siblings ...)
2021-12-10 15:10 ` redi at gcc dot gnu.org
@ 2021-12-10 15:13 ` redi at gcc dot gnu.org
2021-12-10 15:28 ` redi at gcc dot gnu.org
` (11 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-10 15:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
With GCC 10 the same object gets used in the lambda and outside it:
0x7f52ed99f090
0x7f52ed99f090
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (15 preceding siblings ...)
2021-12-10 15:13 ` redi at gcc dot gnu.org
@ 2021-12-10 15:28 ` redi at gcc dot gnu.org
2021-12-19 22:52 ` pinskia at gcc dot gnu.org
` (10 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-10 15:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The difference is due to this change in std::call_once
- __once_callable = std::__addressof(__callable); // NOLINT: PR 82481
- __once_call = []{ (*(decltype(__callable)*)__once_callable)(); };
+ once_flag::_Prepare_execution __exec(__callable);
But I don't know why.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (16 preceding siblings ...)
2021-12-10 15:28 ` redi at gcc dot gnu.org
@ 2021-12-19 22:52 ` pinskia at gcc dot gnu.org
2021-12-19 22:53 ` [Bug libstdc++/103629] [11/12 Regression] " pinskia at gcc dot gnu.org
` (9 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-19 22:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #18 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Could Visibility not being applied correctly to lambdas but does that matter?
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12 Regression] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (17 preceding siblings ...)
2021-12-19 22:52 ` pinskia at gcc dot gnu.org
@ 2021-12-19 22:53 ` pinskia at gcc dot gnu.org
2022-01-04 9:04 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-19 22:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Possible miscompilation |[11/12 Regression] Possible
|visible using pthread + |miscompilation visible
|exception |using pthread + exception
Target Milestone|--- |11.3
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12 Regression] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (18 preceding siblings ...)
2021-12-19 22:53 ` [Bug libstdc++/103629] [11/12 Regression] " pinskia at gcc dot gnu.org
@ 2022-01-04 9:04 ` rguenth at gcc dot gnu.org
2022-04-21 7:50 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-04 9:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-01-04
Ever confirmed|0 |1
Priority|P3 |P2
Status|UNCONFIRMED |NEW
--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
Seems confirmed at least.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12 Regression] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (19 preceding siblings ...)
2022-01-04 9:04 ` rguenth at gcc dot gnu.org
@ 2022-04-21 7:50 ` rguenth at gcc dot gnu.org
2022-08-24 12:14 ` [Bug libstdc++/103629] [11/12/13 " malat at debian dot org
` (6 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21 7:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.3 |11.4
--- Comment #20 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12/13 Regression] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (20 preceding siblings ...)
2022-04-21 7:50 ` rguenth at gcc dot gnu.org
@ 2022-08-24 12:14 ` malat at debian dot org
2022-08-24 12:14 ` malat at debian dot org
` (5 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: malat at debian dot org @ 2022-08-24 12:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #22 from Mathieu Malaterre <malat at debian dot org> ---
Created attachment 53501
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53501&action=edit
working save-temps
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12/13 Regression] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (21 preceding siblings ...)
2022-08-24 12:14 ` [Bug libstdc++/103629] [11/12/13 " malat at debian dot org
@ 2022-08-24 12:14 ` malat at debian dot org
2022-08-24 12:16 ` malat at debian dot org
` (4 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: malat at debian dot org @ 2022-08-24 12:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #23 from Mathieu Malaterre <malat at debian dot org> ---
Created attachment 53502
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53502&action=edit
non-working save-temps
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12/13 Regression] Possible miscompilation visible using pthread + exception
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (22 preceding siblings ...)
2022-08-24 12:14 ` malat at debian dot org
@ 2022-08-24 12:16 ` malat at debian dot org
2022-08-24 12:28 ` [Bug libstdc++/103629] [11/12/13 Regression] wrong-code when mixing mutex with visibility=hidden malat at debian dot org
` (3 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: malat at debian dot org @ 2022-08-24 12:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #24 from Mathieu Malaterre <malat at debian dot org> ---
I have change the openvdb.cc code into:
% cat openvdb.cc
#include "Tree.h"
static std::string do_segfault() { return Tree::treeType(); }
#ifdef VIS
__attribute__((visibility("default")))
#endif
void initialize()
{
do_segfault();
}
Now I can demonstrate that the issue only happen when using the visibility flag
(no-symptom using the default UNIX mechanism to export all symbols).
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12/13 Regression] wrong-code when mixing mutex with visibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (23 preceding siblings ...)
2022-08-24 12:16 ` malat at debian dot org
@ 2022-08-24 12:28 ` malat at debian dot org
2022-08-24 12:30 ` malat at debian dot org
` (2 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: malat at debian dot org @ 2022-08-24 12:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #25 from Mathieu Malaterre <malat at debian dot org> ---
Looks like there is an easy fix (work-around?):
% cat Tree.h
#pragma once
#include <memory>
#include <mutex>
class
#ifdef VIS
__attribute__((visibility("default")))
#endif
Tree {
public:
static const std::string treeType() {
static std::once_flag once;
std::call_once(once, []() {
std::printf("%p\n", &sTreeTypeName);
sTreeTypeName.reset(new std::string());
});
std::printf("%p\n", &sTreeTypeName);
if (!sTreeTypeName)
throw "uhoh";
return *sTreeTypeName;
}
private:
static std::unique_ptr<const std::string> sTreeTypeName;
};
std::unique_ptr<const std::string> Tree::sTreeTypeName;
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12/13 Regression] wrong-code when mixing mutex with visibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (24 preceding siblings ...)
2022-08-24 12:28 ` [Bug libstdc++/103629] [11/12/13 Regression] wrong-code when mixing mutex with visibility=hidden malat at debian dot org
@ 2022-08-24 12:30 ` malat at debian dot org
2023-03-17 7:36 ` malat at debian dot org
2023-05-29 10:06 ` [Bug libstdc++/103629] [11/12/13/14 " jakub at gcc dot gnu.org
27 siblings, 0 replies; 29+ messages in thread
From: malat at debian dot org @ 2022-08-24 12:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #26 from Mathieu Malaterre <malat at debian dot org> ---
This may be related to:
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62280
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12/13 Regression] wrong-code when mixing mutex with visibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (25 preceding siblings ...)
2022-08-24 12:30 ` malat at debian dot org
@ 2023-03-17 7:36 ` malat at debian dot org
2023-05-29 10:06 ` [Bug libstdc++/103629] [11/12/13/14 " jakub at gcc dot gnu.org
27 siblings, 0 replies; 29+ messages in thread
From: malat at debian dot org @ 2023-03-17 7:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
--- Comment #27 from Mathieu Malaterre <malat at debian dot org> ---
Symptom may go away with:
* https://github.com/AcademySoftwareFoundation/openvdb/pull/1589
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug libstdc++/103629] [11/12/13/14 Regression] wrong-code when mixing mutex with visibility=hidden
2021-12-09 13:25 [Bug c++/103629] New: Possible miscompilation triggered by -fvisibility=hidden mathieu.malaterre at gmail dot com
` (26 preceding siblings ...)
2023-03-17 7:36 ` malat at debian dot org
@ 2023-05-29 10:06 ` jakub at gcc dot gnu.org
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103629
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.4 |11.5
--- Comment #28 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.
^ permalink raw reply [flat|nested] 29+ messages in thread