boostorg / boostorg/thread

Segmentation fault in boost tss, thread_specific_ptr

Open
#267 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
214
Forks
171
PR merge metrics
No merged PRs in 30d

Description

Encountered a segmentation fault while using boost::thread_specific_ptr.
It worked completely fine on my laptop but it doesn't work on our NUMA cluster.

```
Thread 1 "cg.C" received signal SIGSEGV, Segmentation fault.
boost::thread_specific_ptr > > >::thread_specific_ptr (this=0x7ffff7ba2b00 <_start>) at /usr/local/include/boost/thread/tss.hpp:68
68 cleanup(detail::heap_new(),detail::do_heap_delete())
```

This is caused during global variable initialization.
I tried to wrap the ```boost::thread_specific_ptr```s around using ```std::optional``` to delay the initialization, and it worked.
Seems like there is some problem during dynamic library loading.
It was the same when,
1. statically linked boost into a dynamic library and linking it into an executable
2. dynamically loading boost into the exectuable
Unfortunately, I can't test statically linking boost to the executable right now.

In case of the ```std::optional``` fix, a segmentation fault is caused during dynamic library unloading.
(see below)

```
Thread 1 "cg.C" received signal SIGSEGV, Segmentation fault.
boost::detail::shared_count::~shared_count (this=, __in_chrg=)
at /usr/local/include/boost/smart_ptr/detail/shared_count.hpp:426
426 if( pi_ != 0 ) pi_->release();
(gdb) quit
A debugging session is active.

Inferior 1 [process 79251] will be killed.

Quit anyway? (y or n) y
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.