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

[adapters] only export get proc table symbols in adapters #727

Merged
merged 1 commit into from
Jul 21, 2023

Conversation

pbalcer
Copy link
Contributor

@pbalcer pbalcer commented Jul 18, 2023

This adds a version script to restrict visiblity of symbols in adapters. This is so that adapters don't use loader ur functions when populating proc tables...

Before:

piotrekpc :: unified-runtime/build/bin ‹adapters-ci*› » UR_ADAPTERS_FORCE_LOAD=../lib/libur_adapter_hip.so ./hello_world
AddressSanitizer:DEADLYSIGNAL
=================================================================
==84218==ERROR: AddressSanitizer: stack-overflow on address 0x7ffe394fefc0 (pc 0x7f843eac49b1 bp 0x7ffe394ff0d0 sp 0x7ffe394fefc0 T0)
    #0 0x7f843eac49b1 in void std::call_once<urInit::$_0>(std::once_flag&, urInit::$_0&&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../include/c++/13.1.1/mutex:897
    #1 0x7f843eac44d2 in urInit /home/piotrek/work/unified-runtime/source/loader/ur_libapi.cpp:48:5
    #2 0x7f843eac472e in urInit /home/piotrek/work/unified-runtime/source/loader/ur_libapi.cpp:61:12
    ...
    #245 0x7f843eac472e in urInit /home/piotrek/work/unified-runtime/source/loader/ur_libapi.cpp:61:12
    #246 0x7f843eac472e in urInit /home/piotrek/work/unified-runtime/source/loader/ur_libapi.cpp:61:12

SUMMARY: AddressSanitizer: stack-overflow /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../include/c++/13.1.1/mutex:897 in void std::call_once<urInit::$_0>(std::once_flag&, urInit::$_0&&)
==84218==ABORTING
piotrekpc :: unified-runtime/build/lib ‹adapters-ci*› » nm libur_adapter_hip.so
...
000000000011b5c0 T urGetUsmP2PExpProcAddrTable
0000000000119ee0 T urGetUSMProcAddrTable
00000000001a6c40 T urInit
0000000000185bc0 T urKernelCreate
000000000018a540 T urKernelCreateWithNativeHandle
...

After:

piotrekpc :: unified-runtime/build/bin ‹adapters-ci*› » UR_ADAPTERS_FORCE_LOAD=../lib/libur_adapter_hip.so ./hello_world
Platform initialized.
API version: 0.6
Found a AMD Radeon RX 7900 XT gpu.

=================================================================
==85366==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 144 byte(s) in 2 object(s) allocated from:
    #0 0x5625a26c0202 in operator new(unsigned long) (/home/piotrek/work/unified-runtime/build/bin/hello_world+0x126202) (BuildId: bf43e9d3666a60ce9d2a785e91b9c26426eabfd0)
    #1 0x7f5095457651  (/opt/rocm/lib/libhsa-runtime64.so.1+0x57651) (BuildId: f7f526d06338fb02490caa9445ee3ad876fcab4f)

    ...

Indirect leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x5625a26c0202 in operator new(unsigned long) (/home/piotrek/work/unified-runtime/build/bin/hello_world+0x126202) (BuildId: bf43e9d3666a60ce9d2a785e91b9c26426eabfd0)
    #1 0x7f5095aa0722  (/opt/rocm/hip/lib/libamdhip64.so.5+0x2a0722) (BuildId: fb16c579f66b7bf10313de1f62a8fd7f64a0f860)

Indirect leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x5625a26c0202 in operator new(unsigned long) (/home/piotrek/work/unified-runtime/build/bin/hello_world+0x126202) (BuildId: bf43e9d3666a60ce9d2a785e91b9c26426eabfd0)
    #1 0x7f4f89da9dab  (/opt/rocm/lib/libamd_comgr.so.2+0x9a9dab) (BuildId: 80900645c6c6d589df59db110a00d470d77ab376)

SUMMARY: AddressSanitizer: 3495 byte(s) leaked in 55 allocation(s).
piotrekpc :: unified-runtime/build/lib ‹adapters-ci*› » nm libur_adapter_hip.so
...
00000000000a76b0 T urGetUsmP2PExpProcAddrTable
00000000000a5fd0 T urGetUSMProcAddrTable
0000000000132d30 t urInit
0000000000111cb0 t urKernelCreate
0000000000116630 t urKernelCreateWithNativeHandle
...

source/adapters/CMakeLists.txt Outdated Show resolved Hide resolved
This adds a version script to restrict visiblity of symbols
in adapters. This is so that adapters don't use loader ur
functions when populating proc tables...
@pbalcer pbalcer merged commit 16a0354 into oneapi-src:adapters Jul 21, 2023
30 checks passed
@pbalcer pbalcer deleted the adapters-map branch July 21, 2023 10:09
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

Successfully merging this pull request may close these issues.

2 participants