Skip to content

Fix data race in on_switch_shutdown_request()#2931

Merged
prsunny merged 2 commits intosonic-net:masterfrom
Yakiv-Huryk:switch_shutdown_data_race
Oct 13, 2023
Merged

Fix data race in on_switch_shutdown_request()#2931
prsunny merged 2 commits intosonic-net:masterfrom
Yakiv-Huryk:switch_shutdown_data_race

Conversation

@Yakiv-Huryk
Copy link
Copy Markdown
Contributor

The data race in on_switch_shutdown_request() is the following:

  • the on_switch_shutdown_request() calls exit() which calls the destructors for global static variables (e.g.BufferOrch::m_buffer_type_maps)
  • in parallel to that, orchagent accesses the global static variables

A fix is to avoid calling the destructors by using quick_exit() instead of exit()

What I did
Changed exit() -> quick_exit() in on_switch_shutdown_request().
Added __lsan_do_leak_check() call for ASAN build.

Why I did it
To address a data race in the on_switch_shutdown_request()

How I verified it

Details if related

The data race in on_switch_shutdown_request() is the following:

* the on_switch_shutdown_request() calls exit() which calls the
destructors for global static variables (e.g.BufferOrch::m_buffer_type_maps)
* in parallel to that, orchagent accesses the global static variables

A fix is to avoid calling the destructors by using quick_exit() instead of exit()

Signed-off-by: Yakiv Huryk <yhuryk@nvidia.com>
@Yakiv-Huryk Yakiv-Huryk requested a review from prsunny as a code owner October 12, 2023 13:14
@prsunny prsunny requested a review from qiluo-msft October 13, 2023 17:36
@qiluo-msft qiluo-msft requested a review from liuh-80 October 13, 2023 18:43
@StormLiangMS
Copy link
Copy Markdown
Contributor

@Yakiv-Huryk have you tested 202305 with this PR?

@prsunny could we have ADO to support this cherry pick?

@dgsudharsan
Copy link
Copy Markdown
Collaborator

@StormLiangMS This is fix for the bug sonic-net/sonic-buildimage#15966

This is not branch specific flow and we have verified this in general. In addition we ran the sanity testing on 202305.

@StormLiangMS
Copy link
Copy Markdown
Contributor

ADO:25592769

StormLiangMS pushed a commit that referenced this pull request Oct 25, 2023
The data race in on_switch_shutdown_request() is the following:

* the on_switch_shutdown_request() calls exit() which calls the destructors for global static variables (e.g.BufferOrch::m_buffer_type_maps) * in parallel to that, orchagent accesses the global static variables

A fix is to avoid calling the destructors by using quick_exit() instead of exit()
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
The data race in on_switch_shutdown_request() is the following:

* the on_switch_shutdown_request() calls exit() which calls the destructors for global static variables (e.g.BufferOrch::m_buffer_type_maps) * in parallel to that, orchagent accesses the global static variables

A fix is to avoid calling the destructors by using quick_exit() instead of exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants