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

[TySan] False positives accessing base class member variables #125079

Open
gbMattN opened this issue Jan 30, 2025 · 1 comment
Open

[TySan] False positives accessing base class member variables #125079

gbMattN opened this issue Jan 30, 2025 · 1 comment
Assignees
Labels
compiler-rt:tysan Type sanitizer false-positive Warning fires when it should not

Comments

@gbMattN
Copy link
Contributor

gbMattN commented Jan 30, 2025

class Base{
public:
    void* first;
    void* second;
};

class Derrived : public Base{};

Derrived derr;

int main(){
    derr.second = nullptr;
    return 0;
}

Results in the following false positive

==191047==ERROR: TypeSanitizer: type-aliasing-violation on address 0x64fe5b465d00 (pc 0x64fe5ab0df8f bp 0x7ffc691b0050 sp 0x7ffc691af7f8 tid 191047)
WRITE of size 8 at 0x64fe5b465d00 with type p1 void (in Base at offset 8) accesses part of an existing object of type Derrived that starts at offset -8
    #0 0x64fe5ab0df8e in main inherited_member.cpp:12:17
@gbMattN gbMattN self-assigned this Jan 30, 2025
@gbMattN gbMattN added compiler-rt compiler-rt:tysan Type sanitizer false-positive Warning fires when it should not and removed new issue labels Jan 30, 2025
@gbMattN
Copy link
Contributor Author

gbMattN commented Jan 30, 2025

Checking what we go into isAliasingLegal with, the TD we are accessing with is p1 void (in Base at offset 8). We were 8 bytes into the type in shadow memory, which is Derrived. The first member TD of Derrived is Base. So it looks like the values we have are correct, the checks just aren't catching this for some reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt:tysan Type sanitizer false-positive Warning fires when it should not
Projects
None yet
Development

No branches or pull requests

3 participants