Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2465 Discussions

Segmentation fault using dlopen/dlclose on Linux

erling_andersen
New Contributor I
2,671 Views

We have created a shared object linking with oneTBB called libA. Now we have created a program called P that opens libA with dlopen(). 

 

However, we get a segmentation fault when libA is dlclosed()!  See the stack trace below.

 

(Context libA is a library we license to be linked into other programs and we have no control over what those other programs links with.)

 

Now calling

 

https://oneapi-src.github.io/oneTBB/main/tbb_userguide/Initializing_and_Terminating_the_Library.html

 

explicit may solve the issue. However, the problem is

 

P

 

may link to other libraries using oneTBB. Is it then safe for libA to call finalize.

 

Or how do we get rid of segmentation fault?

 

Stack trace from gdb:

 

Thread 6 "main" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff4921700 (LWP 889452)]
0x00007ffff5ca37fb in _INTERNALbce07840::tbb::detail::r1::std_cache_aligned_allocate (bytes=256, alignment=128)
at /localdisk/ci/runner006/intel-innersource/001/_work/libraries.threading.infrastructure.onetbb-ci/libraries.threading.infrastructure.onetbb-ci/onetbb_source_code/src/tbb/allocator.cpp:207
207 /localdisk/ci/runner006/intel-innersource/001/_work/libraries.threading.infrastructure.onetbb-ci/libraries.threading.infrastructure.onetbb-ci/onetbb_source_code/src/tbb/allocator.cpp: No such file or directory.
(gdb) bt
#0 0x00007ffff5ca37fb in _INTERNALbce07840::tbb::detail::r1::std_cache_aligned_allocate (bytes=256, alignment=128)
at /localdisk/ci/runner006/intel-innersource/001/_work/libraries.threading.infrastructure.onetbb-ci/libraries.threading.infrastructure.onetbb-ci/onetbb_source_code/src/tbb/allocator.cpp:207
#1 0x00007ffff5ca3705 in tbb::detail::r1::cache_aligned_allocate (size=256)
at /localdisk/ci/runner006/intel-innersource/001/_work/libraries.threading.infrastructure.onetbb-ci/libraries.threading.infrastructure.onetbb-ci/onetbb_source_code/src/tbb/allocator.cpp:192
#2 0x00007ffff5cbe99e in tbb::detail::r1::thread_data::thread_data (this=0x7fffd8000d80, index=8, is_worker=true)
at /localdisk/ci/runner006/intel-innersource/001/_work/libraries.threading.infrastructure.onetbb-ci/libraries.threading.infrastructure.onetbb-ci/onetbb_source_code/src/tbb/thread_data.h:99
#3 0x00007ffff5ccb8b0 in tbb::detail::r1::market::create_one_job (this=0x555555589c80)
at /localdisk/ci/runner006/intel-innersource/001/_work/libraries.threading.infrastructure.onetbb-ci/libraries.threading.infrastructure.onetbb-ci/onetbb_source_code/src/tbb/market.cpp:621
#4 0x00007ffff5cd5ba5 in tbb::detail::r1::rml::private_worker::run (this=0x5555555a4500)
at /localdisk/ci/runner006/intel-innersource/001/_work/libraries.threading.infrastructure.onetbb-ci/libraries.threading.infrastructure.onetbb-ci/onetbb_source_code/src/tbb/private_server.cpp:264
#5 0x00007ffff5cd5eea in tbb::detail::r1::rml::private_worker::thread_routine (arg=0x5555555a4500)
at /localdisk/ci/runner006/intel-innersource/001/_work/libraries.threading.infrastructure.onetbb-ci/libraries.threading.infrastructure.onetbb-ci/onetbb_source_code/src/tbb/private_server.cpp:221
#6 0x00007ffff5b0f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#7 0x00007ffff7edc133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

0 Kudos
10 Replies
SeshaP_Intel
Moderator
2,620 Views

Hi,

 

Thank you for posting in Intel Communities.

 

Have you tried with the latest OneTBB library 2021.8 version? If not, please try and let us know the results.

Could you please provide the following details so that we can reproduce the issue on our end?

1. Source file and the complete steps you have followed.

2. OS details.

3. Hardware details.

 

We can see that you are a priority support customer. So, you can post your query in the below link for priority support:

https://www.intel.com/content/www/us/en/developer/get-help/priority-support.html

 

Thanks and Regards,

Pendyala Sesha Srinivas

 

0 Kudos
erling_andersen
New Contributor I
2,603 Views

1) I upgraded to

 

2021.8

 

and it did not solve the problem.

 

2) Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.4.0-137-generic x86_64)

 

We have also seen the problem in the ARM version.

 

3) If I add

 

// Begin

 

  oneapi::tbb::task_scheduler_handle handle;

  handle = oneapi::tbb::task_scheduler_handle{oneapi::tbb::attach{}};

  try
  {
    oneapi::tbb::finalize(handle);
    // oneTBB worker threads are terminated at this point.
  }
  catch (const oneapi::tbb::unsafe_wait&)
  {
    std::cerr << "Failed to terminate the worker threads." << std::endl;
  }
 
// end
 
to so unloading code. The problem goes away.
 
HOWEVER, I am not sure if there some side effects. I asked about that in the initial post.
 
I am aware I have paid support but it may be faster but also more cumbersome. So it is last resort.
 
0 Kudos
SeshaP_Intel
Moderator
2,545 Views

Hi,


Is your issue resolved after adding the code you mentioned? If resolved please confirm.

It would be better if you provide us with a sample reproducer and steps to reproduce the issue.

If you have any issues sharing the source publicly, you have a choice to send your source code by private message. So if you are willing to send it, please let us know so we can contact you privately.


Thanks and Regards,

Pendyala Sesha Srinivas


0 Kudos
SeshaP_Intel
Moderator
2,479 Views

Hi,


We haven't heard back from you. Could you please provide an update on your issue?


Thanks and Regards,

Pendyala Sesha Srinivas


0 Kudos
erling_andersen
New Contributor I
2,470 Views

Now calling

 

   https://oneapi-src.github.io/oneTBB/main/tbb_userguide/Initializing_and_Terminating_the_Library.html

 

seems to solve the initial issue but then makes the code crash on the linux  @ arm platform.

 

I know I should create a small example showing the issue but that is a lot of work to do so.

0 Kudos
erling_andersen
New Contributor I
2,465 Views

In other words we thinking about what to do.

0 Kudos
SeshaP_Intel
Moderator
2,385 Views

Hi,


Could you please provide the sample reproducer and the steps you followed, so that we can investigate this from our end?

Could you please provide the hardware details you are using?

Have you tried to run the program having an Intel processor in the machine? If yes, could you please share the results with us?


Thanks and Regards,

Pendyala Sesha Srinivas


0 Kudos
erling_andersen
New Contributor I
2,380 Views

Although the issue is not solved then feel free to close the issue.

 

We may contact you on priority support later.

 

0 Kudos
SeshaP_Intel
Moderator
2,348 Views

Hi,


Sure you could reach out to us when you are ready with the sample reproducer. For time being I am closing this issue.

This thread will no longer be monitored by Intel. If you need further assistance, please post a new question. 


Thanks and Regards,

Pendyala Sesha Srinivas


0 Kudos
erling_andersen
New Contributor I
2,320 Views

It seems the issue is known

 

https://github.com/oneapi-src/oneTBB/issues/977

0 Kudos
Reply