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

crash when dlopen/dlclose rust-made *.so multi-times on android/ohos aarch64 #135815

Open
Rust401 opened this issue Jan 21, 2025 · 1 comment
Open
Labels
C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.

Comments

@Rust401
Copy link

Rust401 commented Jan 21, 2025

crash when dlopen/dlclose rust-made *.so multi-times on android/ohos aarch64

Senario:

  1. Compile a Rust source file into a shared object (.so) file.
  2. A C++ file uses dlopen to load the .so file and retrieve the target symbol.
  3. Call the Rust function within the loaded .so.
  4. Use dlclose to unload the .so file.

Related issues #134820

reproduction code

Here's the translation of the provided text:

Known Information:

  1. There is no issue with regular arm64, but disassembly reveals differences involving the use of TPIDR_EL0.
  2. The main difference between ohos/an and arm64 Linux options is has_thread_local=true and tls-model=emulated, but these two compilation options do not seem to take effect when compiling the shared object (suspected that the standard library needs to be recompiled with these options). The implementation of printl is part of the Rust standard library.
  3. Upon reviewing the code, it was found that the tls-model=emulated option affects the rustc compilation behavior (either using TPIDR_EL0 or emulated TLS, by affecting the LLVM backend).

This seems to be a bug in the rustc implementation. In the combination of Android and OHOS target platform options, during the println process, a thread-local variable is implicitly created, and the thread-local resources initialized through lazy_init are not properly released when dlclose is called.

@Rust401 Rust401 added the C-bug Category: This is a bug. label Jan 21, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 21, 2025
@bjorn3
Copy link
Member

bjorn3 commented Jan 21, 2025

What is the difference between the problem in this issue and the one in #134820?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.
Projects
None yet
Development

No branches or pull requests

3 participants