Skip to content

Android UE5: dlopen failed due to TLS model in tracy_rpmalloc.cpp #779

@natepaynefb

Description

@natepaynefb

Hi. Thanks for the great profiler! I'm trying to use it in a UE5 project built for Android and deployed onto a Meta Queset VR headset. It crashes immediately with an error of the form:

java.lang.UnsatisfiedLinkError: dlopen failed: TLS symbol "(null)" in dlopened "<path>/libtracy.so" referenced from "<path>/libtracy.so" using IE access model

The dynamic linker is trying to handle the following variable from tracy_rpmalloc.cpp:

static _Thread_local heap_t* _memory_thread_heap TLS_MODEL;

where TLS_MODEL is defined as:

define TLS_MODEL __attribute__((tls_model("initial-exec")))

I can work around this problem by removing the tls_model attribute. Doing so fixes the crash and does not cause any other problems that I have been able to observe. However, I don't feel confident about this fix because I don't know why the specific TLS model was used in the first place.

I also tried compiling with linker flag -fvisibility=hidden. I was hoping that would hide the variable from the dynamic linker entirely, but it did not.

What would you suggest? Would the following revision to tracy_rpmalloc.cpp cause any problems that you are aware of?

#    if !defined(__HAIKU__) && !defined(__ANDROID__)
#      define TLS_MODEL __attribute__((tls_model("initial-exec")))
#    else
#      define TLS_MODEL
#    endif

In case it matters, here are the other defines used when building Tracy:

         -DTRACY_ENABLE=1,
        -DTRACY_FIBERS=1,
        -DTRACY_ON_DEMAND=1,
        -DTRACY_DELAYED_INIT=1,
        -DTRACY_MANUAL_LIFETIME=1,
        -DTRACY_EXPORTS=1,

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions