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]Why do errors occur when ASAN and UBSAN are opened together? #106933

Open
CoolCaicaixian opened this issue Sep 2, 2024 · 2 comments
Open
Labels
compiler-rt:asan Address sanitizer compiler-rt:ubsan Undefined behavior sanitizer

Comments

@CoolCaicaixian
Copy link

CoolCaicaixian commented Sep 2, 2024

Env Info:

【Compile Sdk Version】33
【NDK Version】R21e
【JDK】Java 8

Error Info:

2024-08-29 09:55:10.324 18568-18568 app_process64           com.cwx.inanna_android             I  /Users/cwx/work/codes/gitCodes/inanna/inanna-framework/demos/android/inanna-android/app/src/main/cpp/native-lib.cpp:42:22: runtime error: member call on address 0x0041793d7bf0 which does not point to an object of type 'Base'
2024-08-29 09:55:10.324 18568-18568 app_process64           com.cwx.inanna_android             I  0x0041793d7bf0: note: object is of type 'Derived'
2024-08-29 09:55:10.324 18568-18568 app_process64           com.cwx.inanna_android             I   00 00 00 00  f0 95 db 13 71 00 00 00  00 00 00 00 be be be be  02 11 00 00 10 00 00 00  5b 27 00 00
2024-08-29 09:55:10.324 18568-18568 app_process64           com.cwx.inanna_android             I                ^~~~~~~~~~~~~~~~~~~~~~~
2024-08-29 09:55:10.324 18568-18568 app_process64           com.cwx.inanna_android             I                vptr for 'Derived'

C++ Code:

// Base.h
class Base {
public:
    virtual ~Base();
    virtual int foo();  
    int bar();         
};

// Base.cpp
Base::~Base()
{
}
int Base::foo()
{
    return 1;
}
int Base::bar() {
    return 2;
}

// Derived.h
class Derived : public Base {
public:
    int foo() override; 
};

// Derived.cpp
int Derived::foo() {
    return bar() + Base::foo();
}

int init() {
    Base *pBase = new Derived();
    int ret = pBase->foo();
    delete pBase;
    return ret;
}

### cmake options:

target_compile_options(inanna_android PUBLIC -fsanitize=address -fno-omit-frame-pointer)
target_link_options(inanna_android PUBLIC -fsanitize=address)
target_compile_options(inanna_android PUBLIC -fsanitize=undefined -fno-sanitize-recover=undefined)
target_link_options(inanna_android PUBLIC -fsanitize=undefined -fno-sanitize-recover=undefined)

described:

When I turned on one of the options separately, it worked well.Or if I turn off the vptr check, it can work well,but when i both open ASAN and UBASAN,the error coming...

@asl asl added compiler-rt:asan Address sanitizer compiler-rt:ubsan Undefined behavior sanitizer and removed new issue labels Sep 2, 2024
@CoolCaicaixian
Copy link
Author

mark

@CoolCaicaixian
Copy link
Author

seen in detail:android/ndk#2065

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt:asan Address sanitizer compiler-rt:ubsan Undefined behavior sanitizer
Projects
None yet
Development

No branches or pull requests

2 participants