Skip to content

Fix intermittent shutdown SIGSEGV: reset content downloader handle in UnloadAllExtensions - #909

Open
Buell (JanZachmann) wants to merge 1 commit into
Azure:developfrom
JanZachmann:upstream-fix/extmgr-shutdown-dlsym
Open

Fix intermittent shutdown SIGSEGV: reset content downloader handle in UnloadAllExtensions#909
Buell (JanZachmann) wants to merge 1 commit into
Azure:developfrom
JanZachmann:upstream-fix/extmgr-shutdown-dlsym

Conversation

@JanZachmann

Copy link
Copy Markdown

Fixes #908

What

Fix the intermittent shutdown SIGSEGV in ld.so: ExtensionManager::Uninit()
runs twice at shutdown, and the second UnloadAllExtensions() did
dlsym(_contentDownloader, "Cleanup") on a content-downloader handle the first
call had already dlclosed. do_lookup_x then walked a freed link_map.

Fix

Reset _contentDownloader and its contract version after the dlclose loop, so
the second unload is a no-op.

Tests

  • New regression test: two Uninit() calls must not reuse the handle.
  • Fixed the existing "Uninit clears ... downloader library state" test, which
    asserted the buggy "not cleared" behaviour.
  • Both fail without the fix, pass with it.

Root-caused from a symbolized core; details in the linked issue.

ExtensionManager::Uninit() runs twice on shutdown (via
AzureDeviceUpdateCoreInterface_Destroy and via ExtensionManager_Uninit).
UnloadAllExtensions() dlclose'd the content downloader library but left the
static _contentDownloader handle and its V2 contract flag set, so the second
call did dlsym(_contentDownloader, "Cleanup") on the freed handle. glibc's
do_lookup_x then walked a freed link_map and crashed intermittently with
SIGSEGV inside ld.so during agent shutdown (exit-only; agent restarts fine).

Reset _contentDownloader and its contract version after the dlclose loop so a
repeat unload is a no-op. Root-caused from a symbolized device core.

Add a regression test (Uninit twice must not reuse the handle) and fix the
existing "Uninit clears ... downloader library state" test, which had asserted
the buggy "not cleared" behavior.

Pristine 1.4.0 bug (upstream), not introduced by the omnect port.

Signed-off-by: Jan Zachmann 50990105+JanZachmann@users.noreply.github.com
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.

Intermittent SIGSEGV in ld.so during agent shutdown (dlsym on unloaded content downloader)

1 participant