Azure / Azure/iot-hub-device-update
Intermittent SIGSEGV in ld.so during agent shutdown (dlsym on unloaded content downloader)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 61
- Forks
- 54
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 1
Description
Summary
AducIotAgent intermittently crashes with SIGSEGV inside the dynamic loader
(ld-linux.so) during shutdown. Exit-only — the agent restarts fine, but
systemd records the stop as core-dump. Seen on aarch64, 1.4.0.
Root cause
ExtensionManager::Uninit() runs twice during shutdown:
- via
AzureDeviceUpdateCoreInterface_Destroy(linux_adu_core_impl.cpp, from
ADUC_PnP_Components_Destroy), and - via
ExtensionManager_Uninit()in the agent'sShutdownAgent(main.c).
ExtensionManager::UnloadAllExtensions() dlcloses the content-downloader
library (in _libs) and clears _libs, but never resets the static
_contentDownloader handle or _contentDownloaderContractVersion. So the second
call still sees _contentDownloader != nullptr and a V2 contract, and runs
dlsym(_contentDownloader, "Cleanup") on the freed handle. glibc's
do_lookup_x then walks a freed link_map → intermittent SEGV_MAPERR
(intermittent because the freed memory is sometimes still mapped).
Symbolized crashing stack (from a device core):
do_lookup_x (undef_name="Cleanup", undef_map=<freed link_map>) ld.so
_dl_lookup_symbol_x -> do_sym -> _dl_sym -> ___dlsym
ExtensionManager::UnloadAllExtensions() extension_manager.cpp:418
ShutdownAgent -> ExtensionManager_Uninit
Reproduces when
A V2-contract content downloader is loaded (curl is the default in 1.4.0) and
the agent is stopped (SIGTERM) — e.g. during an OS update. Intermittent.
Fix
Reset _contentDownloader and _contentDownloaderContractVersion after the
dlclose loop in UnloadAllExtensions() so a repeat Uninit is a no-op. PR
attached.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in extension_manager.cpp at UnloadAllExtensions(), around line 418, and trace the shutdown paths through linux_adu_core_impl.cpp and main.c. Verify that repeated Uninit calls no longer use the unloaded content-downloader handle; done means SIGTERM shutdown does not reach dlsym with a freed handle.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- embedded-iot, operating-systems
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100