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

【Android】Why do errors occur when ASAN and UBSAN are opened together? #1787

Open
CoolCaicaixian opened this issue Aug 29, 2024 · 0 comments

Comments

@CoolCaicaixian
Copy link

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 normally

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

No branches or pull requests

1 participant