Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitizer error in tbb #140

Closed
marcomanno opened this issue May 7, 2019 · 10 comments
Closed

Sanitizer error in tbb #140

marcomanno opened this issue May 7, 2019 · 10 comments

Comments

@marcomanno
Copy link

Building my project with option -fsanitize I get this error:

../TBB-2017U5-0226-headers/inc/tbb/task.h:749:49: runtime error: member call on address 0x7fbe9802bc00 which does not point to an object of type 'scheduler'
0x7fbe9802bc00: note: object is of type 'tbb::internal::custom_schedulertbb::internal::IntelSchedulerTraits'
00 00 00 00 f0 ab 7f a0 be 7f 00 00 00 00 00 00 00 00 00 00 e0 be 02 98 be 7f 00 00 e0 be 02 98
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'tbb::internal::custom_schedulertbb::internal::IntelSchedulerTraits'

I believe that the problem is here: class custom_scheduler: private generic_scheduler
The private inheritance make the cast from class custom_scheduler to class generic_scheduler not defined, and then the method:
void spawn_and_wait_for_all( task& child ) {
prefix().owner->wait_for_all( *this, &child );
}
has an undefined behaviour.
I do not know if my analysis is correct, but I if you could fix it in some way...

@alexey-katranov
Copy link
Contributor

alexey-katranov commented May 7, 2019

It is a weird approach that we use potentially invalid pointer (owner) to enter the library. Inside the library we do not use this pointer but read it from tls. See the comment.
UPDATE: We realized that it might be dangerous in some cases. I will conduct some research and share the result if any.

@marcomanno
Copy link
Author

Hi, this issue is preventing us from using some option of the gcc sanitizer.
The environment is quite complex and my initial analysis was probably wrong.
If do not have time to fully understand the tbb code.
At this point is up to you to fix the issue or to find a workaround.

@qhaas
Copy link

qhaas commented Jun 7, 2019

Seeing these errors in TBB 4.4.6 (we are stuck on this version for now, but plan to upgrade to the latest release in the medium-term), GCC6, and centos7 with sanitize. Thought it might be related to the issues described here and/or TBB constructs in the std namespace, so rebuilt TBB with -DTBB_USE_GCC_BUILTINS and specified the C++11 standard / gcc compiler via flags to its Makefile, but still get said errors and don't have the time to troubleshoot any deeper.

@alexey-katranov
Copy link
Contributor

We are working on a workaround but it will be available in a future release. Currently, I do not know how to avoid the issue with TBB 4.4.6 without TBB runtime modifications. Perhaps, you can rework the application to guarantee prefix().owner lifetime but it can be a challenge. Do you have a sanitizer issue for any TBB code or it should be non-trivial?

@qhaas
Copy link

qhaas commented Jun 10, 2019

Thanks for the feedback @alexey-katranov . Please update this issue when TBB is updated upstream to address this, we might be able to upgrade to the latest TBB release by then.

@marcomanno
Copy link
Author

Thanks for your work. I will update tbb as soon there is a release where the issue is fixed.

@alexey-katranov
Copy link
Contributor

The private inheritance make the cast from class custom_scheduler to class generic_scheduler not defined

FYI. Making the inheritance public does not solve the issue. We tried a couple of workarounds but they also did not help. It looks like some sanitizer issue. We will continue investigation to understand the root cause but it might take some time.

@ghost
Copy link

ghost commented Jun 25, 2019

Here I have the same problem, but at different places:

*/TBB/include/tbb/task.h:779:49
*/TBB/include/tbb/task.h:1046:28

contexts:

778 static void spawn_root_and_wait( task& root ) {
779 root.prefix().owner->spawn_root_and_wait( root, root.prefix().next );
780 }

1045 inline void interface5::internal::task_base::spawn( task& t ) {
1046 t.prefix().owner->spawn( t, t.prefix().next );
1047 }

Manjaro Linux, gcc 8.3.0, tbb 2019.0

@anton-potapov
Copy link
Contributor

@marcomanno recently oneTBB got a lot of Sanitizer related fixes. Could you please check if this issue is still reproducible with latest master?

@anton-potapov
Copy link
Contributor

@marcomanno please reopen if the problem still exist with oneTBB 2021.4 or latest master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants