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

[BUG] ndk stl std::thread crash #1017

Closed
doyee opened this issue Jun 21, 2019 · 6 comments
Closed

[BUG] ndk stl std::thread crash #1017

doyee opened this issue Jun 21, 2019 · 6 comments
Labels

Comments

@doyee
Copy link

doyee commented Jun 21, 2019

NDK Version: all NDK with APP_STL :=c++_static , tested from NDK 13,
Build system: ndk-build
Host OS: Mac OS
ABI:arm64-v8a
NDK API level: APP_PLATFORM := android-24
Device API level: not set
run this demo on android device with current O or P version,
if set APP_STL := c++_static, crash occurred when outside loop i = 128,
if set APP_STL := gnustl_static, there is no crash.
but after NDK r18, there is only c++_static. I have to use NDK R17 with gnustl_static

test demo and so, the flow is:
demo:

main()
{
  for(i=0; i<1000; i++)
  {
    dlopen so
    for(int j=0; j<1; j++)
    {
      call process_func() in so
    }
    dlclose so
  }
}

so:

process_func()
{
  call std::thread and join
}

please use this link for debug:
https://github.com/doyee/ndk-bug-thread-crash

JNITest.cpp dlopen(ThreadTest.so)
ThreadTest.so will use std::thread

@doyee doyee added the bug label Jun 21, 2019
@DanAlbert
Copy link
Member

tested from NDK 13

We've fixed tons of bugs since then, especially around issues like this. Try with r20.

@DanAlbert DanAlbert reopened this Jun 21, 2019
@DanAlbert
Copy link
Member

(or do I misunderstand and you mean this bug is present in every version since r13?)

@DanAlbert
Copy link
Member

DanAlbert commented Jun 21, 2019

dlclose so

Actually, that's probably your problem. Don't call dlcose and the bug will go away. See #360 for the gory details.

(if that's not the case, lmk and I'll reopen)

@DanAlbert
Copy link
Member

Another bug that might be the problem (actually seems more likely): #789

@doyee
Copy link
Author

doyee commented Jun 22, 2019

@DanAlbert I ALREADY use the latest ndk, still has this problem, you can check my code in JNITest.cpp, if use local DllHelper obj for dlopen dlclose, this crash happen. if use global DllHelper no crash

@DanAlbert
Copy link
Member

Yeah, I hadn't fully understood in my first post, but what about the others? I think my most recent post is probably the source of your problems.

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

No branches or pull requests

2 participants