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

[asan] suppress the static variable leaks #1085

Merged
merged 2 commits into from
Aug 9, 2022

Conversation

Yakiv-Huryk
Copy link
Contributor

This is to suppress ASAN false positives for static variables.
For example, the ServiceMethodTable::m_slots is sometimes reported as leaked.

ASAN report example:

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7feb0d3f4647 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x55b3be15e430 in declare_static<syncd::ServiceMethodTable::SlotBase, syncd::ServiceMethodTable::Slot, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9> syncd/ServiceMethodTable.cpp:74
    #2 0x55b3be15e430 in declare_static<syncd::ServiceMethodTable::SlotBase, syncd::ServiceMethodTable::Slot, 10> syncd/ServiceMethodTable.cpp:81
    #3 0x55b3be15e430 in __static_initialization_and_destruction_0 syncd/ServiceMethodTable.cpp:85
    #4 0x55b3be15e430 in _GLOBAL__sub_I_ServiceMethodTable.cpp syncd/ServiceMethodTable.cpp:121

This is to suppress ASAN false positives for static variables.
For example, the ServiceMethodTable::m_slots is sometimes reported as
leaked.

Signed-off-by: Yakiv Huryk <[email protected]>
syncd/Asan.cpp Outdated
Comment on lines 6 to 11
extern "C" {
const char* __lsan_default_suppressions() {
return "leak:__static_initialization_and_destruction_0\n";
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sounds really bad, you are implementing missing import here, why this way ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is rather a callback than a missing import. This is one of the ways to configure ASAN/LSAN.
Another way is to have a file (e.g. supressions.txt) and pass a path to it via env variable options.
The 'callback' approach is simpler and allows to keep all the asan-related things in asan.cpp.
This also seems to be a more popular way to configure the suppressions (e.g. chromium does this).

kcudnik
kcudnik previously approved these changes Jul 21, 2022
@kcudnik
Copy link
Collaborator

kcudnik commented Jul 21, 2022

please fix build errors

@liat-grozovik
Copy link
Collaborator

@kcudnik could you please help to merge?

@kcudnik kcudnik merged commit ffc4109 into sonic-net:master Aug 9, 2022
dprital added a commit to dprital/sonic-buildimage that referenced this pull request Aug 29, 2022
Update sonic-sairedis submodule pointer to include the following:
* Run 20 vs tests at a time. ([sonic-net#1111](sonic-net/sonic-sairedis#1111))
* [asan] suppress the static variable leaks ([sonic-net#1085](sonic-net/sonic-sairedis#1085))
* [sonic-sairedis] Support bulk counter ([sonic-net#1094](sonic-net/sonic-sairedis#1094))
* Transfer organization from Azure to sonic-net ([sonic-net#1095](sonic-net/sonic-sairedis#1095))
* [BFN] Provide unified approach to select P4 profile based on chip family ([sonic-net#1089](sonic-net/sonic-sairedis#1089))

Signed-off-by: dprital <[email protected]>
mlorrillere added a commit to mlorrillere/sonic-buildimage that referenced this pull request Sep 8, 2022
* 660a920 [Chassis] Create fabric ports for switch_type fabric. (sonic-net/sonic-sairedis#1114)
* 8140c22 Fix issue: bulk counter feature cannot compile on platforms having no sai_bulk_object_get_stats/sai_bulk_object_clear_stats (sonic-net/sonic-sairedis#1105)
* 0aa60f5 [lgtm] Add uuid library (sonic-net/sonic-sairedis#1119)
* e8a01a8 Add retry on zmq functions if fail with EINTR. (sonic-net/sonic-sairedis#1109)
* 594b242 Add SAI_PORT_ATTR_OPER_SPEED support (sonic-net/sonic-sairedis#1107)
* 4c9e048 Add Xsight specific syncd start options (sonic-net/sonic-sairedis#1112)
* da26ace Run 20 vs tests at a time. (sonic-net/sonic-sairedis#1111)
* ffc4109 [asan] suppress the static variable leaks (sonic-net/sonic-sairedis#1085)
* bfd37e3 [sonic-sairedis] Support bulk counter (sonic-net/sonic-sairedis#1094)
* 90ba09a Transfer organization from Azure to sonic-net (sonic-net/sonic-sairedis#1095)
* 4853881 [BFN] Provide unified approach to select P4 profile based on chip family (sonic-net/sonic-sairedis#1089)
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
* [asan] suppress the static variable leaks

This is to suppress ASAN false positives for static variables.
For example, the ServiceMethodTable::m_slots is sometimes reported as
leaked.

Signed-off-by: Yakiv Huryk <[email protected]>

* [asan] add missing SWSS_LOG_ENTER()

Signed-off-by: Yakiv Huryk <[email protected]>
Yakiv-Huryk added a commit to Yakiv-Huryk/sonic-sairedis that referenced this pull request Nov 24, 2022
* [asan] suppress the static variable leaks

This is to suppress ASAN false positives for static variables.
For example, the ServiceMethodTable::m_slots is sometimes reported as
leaked.

Signed-off-by: Yakiv Huryk <[email protected]>

* [asan] add missing SWSS_LOG_ENTER()

Signed-off-by: Yakiv Huryk <[email protected]>
Yakiv-Huryk added a commit to Yakiv-Huryk/sonic-sairedis that referenced this pull request Dec 6, 2022
* [asan] suppress the static variable leaks

This is to suppress ASAN false positives for static variables.
For example, the ServiceMethodTable::m_slots is sometimes reported as
leaked.

Signed-off-by: Yakiv Huryk <[email protected]>

* [asan] add missing SWSS_LOG_ENTER()

Signed-off-by: Yakiv Huryk <[email protected]>
bingwang-ms pushed a commit that referenced this pull request Jan 3, 2023
* [asan] suppress the static variable leaks

This is to suppress ASAN false positives for static variables.
For example, the ServiceMethodTable::m_slots is sometimes reported as
leaked.

Signed-off-by: Yakiv Huryk <[email protected]>
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.

3 participants