MuleDebug: PIE-translate addresses for the addr2line fallback too - #678
Conversation
|
Mmmmh, not working on my Debian 13.4, no backtrace is printed, the program just exists: |
|
@danim7 -- I reproduced your exact Without your gdb output I can only guess. Could you run: The Two specific theories worth ruling in/out from your build:
Worth doing both before chasing #678 specifically, because nothing in #678's no-bfd code path looks like it could produce a raw SIGTRAP -- the failure mode I'd expect from a bug in my code would be SIGSEGV or an unhandled exception, not SIGTRAP. |
|
Thanks @got3nks for your details instructions. I will test and report back later today. |
same PIE bug. Reported by danim7 on the amule-project#677 thread after they uninstalled libbfd to test the fallback: amule frames came back as "??", and running addr2line manually with the same arguments produced the same empty output -- the addr2line tool expects link-time addresses, but the fallback hands it runtime PCs. Hoist the s_pie_base + find_pie_base_cb + dl_iterate_phdr plumbing out of the #ifdef HAVE_BFD block into the shared Linux scope so both paths can use it. Wrap the actual lookup in init_pie_base() (idempotent, no-op on subsequent calls) so the bfd path's init_backtrace_info() and the no-bfd path of get_backtrace() both seed it at the right moment without duplicating the dl_iterate_phdr call. In the no-bfd branch, translate each runtime PC by subtracting s_pie_base before formatting into the addr2line command line. For PIE binaries this yields the link-time address addr2line expects. For non-PIE binaries s_pie_base is 0 (dlpi_addr is 0 for ET_EXEC) so the subtraction is a no-op and the addr2line invocation is byte-identical to before -- no regression possible on the non-PIE path. Symmetric to amule-project#677. The two paths now use the same offset under the same conditions and would either both work or both break on the same kind of input.
a598992 to
f41cedf
Compare
|
Somehow, the first gdb step about handling SIGTRAP makes the program not to run: If I omit the first step, I can run it with the following result: Concerning your first question, nothing shows up: For the 2nd question, I retrieved version 543b716 and it shows the same behaviour: |
amule-project#678 follow-up reported by danim7. The addr2line fallback in get_backtrace() called wxExecute(cmd, out) to run addr2line. In GUI mode (amule), wxExecute on Linux waits for the child via wxGUIAppTraits::WaitForChild which runs a nested wx event loop -- RunLoopUntilChildExit -> wxEventLoopBase::Run -> wxGUIEventLoop:: DoRun -> gtk_main -> g_main_loop_run -> wxApp::DoIdle -> ProcessPendingEvents. If the wxASSERT that brought us into get_backtrace() came from a periodic / event-driven handler (OnCoreTimer, socket events, etc.), the nested loop fires the same handler again, re-enters wxASSERT, and the second-level wx assert handler can't run amule's reentrantly so it falls through to wxTrap()'s int3 instruction, delivering SIGTRAP and a "Trace/breakpoint trap" termination with no backtrace printed at all. Reproducer per danim7 in PR amule-project#678 discussion: wxASSERT(false) wired into CamuleApp::OnCoreTimer. amuled doesn't reproduce because the console build's wxExecute(cmd, out) uses a plain waitpid loop with no nested event loop -- only the GUI build has the GUI-trait WaitForChild path. Replace wxExecute with popen() / fgets() / pclose() -- a plain fork+pipe+waitpid pipeline with no wx event-loop involvement. The recursive-assert path simply doesn't exist anymore. Output parsing is identical (line-by-line into the same wxArrayString that the old wxExecute populated). Doesn't affect the libbfd path (which is in-process and doesn't fork at all). Recommended fix for users hitting wxASSERTs from periodic handlers is still install binutils-dev so libbfd is the live path; this PR ensures the addr2line fallback no longer deadlocks-then-traps on the same input either.
|
@danim7 -- your gdb output nailed it. Recursive One thing we couldn't do locally though: I tried to reproduce your SIGTRAP on our aarch64 Ubuntu VM (wxGTK 3.2.9 + the exact same Could you cherry-pick #682 onto your tree and re-run your reproducer? If the trap is gone, we've confirmed it. If it's still there, the gdb backtrace from the new build will show whether the popen path even ran (and we'd need a different fix). Either way the popen path is a strict structural improvement -- it removes the only place |
#678 follow-up reported by danim7. The addr2line fallback in get_backtrace() called wxExecute(cmd, out) to run addr2line. In GUI mode (amule), wxExecute on Linux waits for the child via wxGUIAppTraits::WaitForChild which runs a nested wx event loop -- RunLoopUntilChildExit -> wxEventLoopBase::Run -> wxGUIEventLoop:: DoRun -> gtk_main -> g_main_loop_run -> wxApp::DoIdle -> ProcessPendingEvents. If the wxASSERT that brought us into get_backtrace() came from a periodic / event-driven handler (OnCoreTimer, socket events, etc.), the nested loop fires the same handler again, re-enters wxASSERT, and the second-level wx assert handler can't run amule's reentrantly so it falls through to wxTrap()'s int3 instruction, delivering SIGTRAP and a "Trace/breakpoint trap" termination with no backtrace printed at all. Reproducer per danim7 in PR #678 discussion: wxASSERT(false) wired into CamuleApp::OnCoreTimer. amuled doesn't reproduce because the console build's wxExecute(cmd, out) uses a plain waitpid loop with no nested event loop -- only the GUI build has the GUI-trait WaitForChild path. Replace wxExecute with popen() / fgets() / pclose() -- a plain fork+pipe+waitpid pipeline with no wx event-loop involvement. The recursive-assert path simply doesn't exist anymore. Output parsing is identical (line-by-line into the same wxArrayString that the old wxExecute populated). Doesn't affect the libbfd path (which is in-process and doesn't fork at all). Recommended fix for users hitting wxASSERTs from periodic handlers is still install binutils-dev so libbfd is the live path; this PR ensures the addr2line fallback no longer deadlocks-then-traps on the same input either.
…emoveFile Issue #685 (JamesOlvertone): amuled crashed after renaming a file in Incoming with shared-dir watching enabled. Last log lines CFile: Error when opening file (/aMule/Incoming/foo.bar): No such ... Failed to open file (foo.bar), removing from list of shared files. place the crash at CUploadDiskIOThread::StartCreateNextBlockPackage calling theApp->sharedfiles->RemoveFile(srcfile) from a worker thread. Backtrace was addresses-only (build predated #678 + binutils-dev not installed), but two structurally-real races on m_keywords exist: CSharedFileList::list_mut is the outer lock for both m_Files_map and m_keywords. m_keywords is a CPublishKeywordList holding a std::list<CPublishKeyword*> + std::map<wxString, ...> and has no internal locking; AddFile / RemoveFile / FindSharedFiles map-clear all take list_mut around their m_keywords calls. But: 1. CSharedFileList::Reload called m_keywords->RemoveAllKeywordReferences and m_keywords->PurgeUnreferencedKeywords without list_mut. When the user renames a file under a watched dir, CSharedDirWatcher:: OnFileSystemEvent fires ScheduleReload on the main thread. If CUploadDiskIOThread is concurrently uploading that file, it sees CFile::Open fail and calls RemoveFile from the worker thread (the only RemoveFile call site that is not on the main thread). Worker holds list_mut while mutating m_keywords via RemoveKeywords; main thread iterates m_lstKeywords / m_keywordIndex / individual CPublishKeyword::references in parallel without the lock. Result: iterator invalidation, ref-count race, or use-after-free of CPublishKeyword*. 2. CSharedFileList::Publish's keyword-publish section reads + mutates pPubKw (cursor advance via GetNextKeyword, GetReferences iteration, RotateReferences, SetNextPublishTime, IncPublishedCount) without list_mut. Same worker race shape -- worker's RemoveKeyword decrements ref counts and removes pFile from pPubKw->references concurrently with main thread's read/iterate. Wrap both call sites with list_mut. Cannot lock the whole Reload because FindSharedFiles walks the filesystem and would block the worker pool for seconds; the lock is scoped tightly around the two keyword ops there. Publish's keyword section is wrapped wholesale -- Kad calls (PrepareLookup, StartSearch, Search::Go, GetClosestTo, SendFindValue) do not re-enter list_mut, so holding the lock across them is safe. The source/notes publish sections (which call GetCount + GetFileByIndex, both of which internally lock) are intentionally left outside the new lock scope to avoid recursive acquisition.
CamuleApp (amule.cpp) and CamuleDaemonApp both install a wxApp::OnFatalException override that prints a libbfd/addr2line- resolved in-process backtrace on SIGSEGV / SIGBUS / SIGABRT via get_backtrace(). CamuleRemoteGuiApp doesn't, so when amulegui crashes the wx default handler runs and exits without producing any amule frames -- making diagnosis of GTK-callback-into-stale- widget bugs (such as #692, search-tab close while results are streaming) a guessing game even with a saved core, because the core itself only sees gtk_main / libgtk frames and the systemd coredump trace can't see into amule's process state at crash time. Mirror the existing CamuleApp::OnFatalException body in CamuleRemoteGuiApp so amulegui's next crash dumps the same backtrace amule(d) already do -- including the libbfd PIE fixes from #677 / #678 that recently went in. Body is intentionally a copy of CamuleApp::OnFatalException (only the program name in the message differs) rather than refactored into CamuleAppCommon: the latter is not a wxApp derivative so the virtual override has to live on each wxApp-derived class anyway, and a shared helper for the 18-line message string is not worth the indirection. #if wxUSE_ON_FATAL_EXCEPTION guard matches amule.cpp.
Translated using Weblate (Tamil) Currently translated at 0.8% (2 of 246 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/ta/ Translated using Weblate Translated using Weblate (Tamil) Currently translated at 1.2% (24 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/ta/ Translated using Weblate Translated using Weblate (Latvian) Currently translated at 56.9% (140 of 246 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/lv/ Translated using Weblate Translated using Weblate (Latvian) Currently translated at 29.8% (567 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/lv/ Translated using Weblate Translated using Weblate (Chinese (Traditional Han script)) Currently translated at 87.2% (218 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/zh_Hant/ Translated using Weblate Translated using Weblate (Turkish) Currently translated at 98.4% (246 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/tr/ Translated using Weblate Translated using Weblate (Russian) Currently translated at 87.2% (218 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/ru/ Translated using Weblate Translated using Weblate (Romanian) Currently translated at 87.2% (218 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/ro/ Translated using Weblate Translated using Weblate (Portuguese (Brazil)) Currently translated at 97.2% (243 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/pt_BR/ Translated using Weblate Translated using Weblate (Italian) Currently translated at 100.0% (250 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/it/ Translated using Weblate Translated using Weblate (Hungarian) Currently translated at 87.2% (218 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/hu/ Translated using Weblate Translated using Weblate (French) Currently translated at 98.4% (246 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/fr/ Translated using Weblate Translated using Weblate (Spanish) Currently translated at 98.4% (246 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/es/ Translated using Weblate Translated using Weblate (German) Currently translated at 96.8% (242 of 250 strings) Translation: aMule/Application Man Pages Translate-URL: https://hosted.weblate.org/projects/amule/application-man-pages/de/ Translated using Weblate Translated using Weblate (Chinese (Traditional Han script)) Currently translated at 81.4% (1549 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/zh_Hant/ Translated using Weblate Translated using Weblate (Chinese (Simplified Han script)) Currently translated at 97.4% (1852 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/zh_Hans/ Translated using Weblate Translated using Weblate (Chinese (Simplified Han script)) Currently translated at 97.4% (1852 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/zh_Hans/ Translated using Weblate Translated using Weblate (Ukrainian) Currently translated at 75.0% (1426 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/uk/ Translated using Weblate Translated using Weblate (Turkish) Currently translated at 97.1% (1847 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/tr/ Translated using Weblate Translated using Weblate (Swedish) Currently translated at 82.1% (1562 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/sv/ Translated using Weblate Translated using Weblate (Albanian) Currently translated at 61.1% (1163 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/sq/ Translated using Weblate Translated using Weblate (Slovenian) Currently translated at 82.3% (1566 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/sl/ Translated using Weblate Translated using Weblate (Russian) Currently translated at 81.2% (1545 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/ru/ Translated using Weblate Translated using Weblate (Romanian) Currently translated at 82.1% (1561 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/ro/ Translated using Weblate Translated using Weblate (Portuguese (Portugal)) Currently translated at 81.3% (1546 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/pt_PT/ Translated using Weblate Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1901 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/pt_BR/ Translated using Weblate Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1901 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/pt_BR/ Translated using Weblate Translated using Weblate (Polish) Currently translated at 79.3% (1508 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/pl/ Translated using Weblate Translated using Weblate (Norwegian Nynorsk) Currently translated at 68.2% (1298 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/nn/ Translated using Weblate Translated using Weblate (Dutch) Currently translated at 82.7% (1574 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/nl/ Translated using Weblate Translated using Weblate (Lithuanian) Currently translated at 68.2% (1298 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/lt/ Translated using Weblate Translated using Weblate (Korean) Currently translated at 56.6% (1077 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/ko/ Translated using Weblate Translated using Weblate (Japanese) Currently translated at 62.5% (1189 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/ja/ Translated using Weblate Translated using Weblate (Italian) Currently translated at 100.0% (1901 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/it/ Translated using Weblate Translated using Weblate (Italian) Currently translated at 100.0% (1901 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/it/ Translated using Weblate Translated using Weblate (Hungarian) Currently translated at 86.9% (1652 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/hu/ Translated using Weblate Translated using Weblate (Croatian) Currently translated at 24.5% (467 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/hr/ Translated using Weblate Translated using Weblate (Hebrew) Currently translated at 44.5% (847 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/he/ Translated using Weblate Translated using Weblate (Galician) Currently translated at 86.7% (1649 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/gl/ Translated using Weblate Translated using Weblate (French) Currently translated at 97.1% (1847 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/fr/ Translated using Weblate Translated using Weblate (Finnish) Currently translated at 81.5% (1551 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/fi/ Translated using Weblate Translated using Weblate (Basque) Currently translated at 81.5% (1551 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/eu/ Translated using Weblate Translated using Weblate (Estonian) Currently translated at 80.4% (1530 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/et/ Translated using Weblate Translated using Weblate (Spanish) Currently translated at 96.8% (1842 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/es/ Translated using Weblate Translated using Weblate (Greek) Currently translated at 71.7% (1364 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/el/ Translated using Weblate Translated using Weblate (German) Currently translated at 88.0% (1673 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/de/ Translated using Weblate Translated using Weblate (Danish) Currently translated at 24.1% (460 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/da/ Translated using Weblate Translated using Weblate (Czech) Currently translated at 65.1% (1239 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/cs/ Translated using Weblate Translated using Weblate (Czech) Currently translated at 65.1% (1239 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/cs/ Translated using Weblate Translated using Weblate (Catalan) Currently translated at 83.0% (1578 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/ca/ Translated using Weblate Translated using Weblate (Bulgarian) Currently translated at 13.5% (257 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/bg/ Translated using Weblate Translated using Weblate (Asturian) Currently translated at 75.8% (1442 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/ast/ Translated using Weblate Translated using Weblate (Arabic) Currently translated at 15.9% (304 of 1901 strings) Translation: aMule/Application Translate-URL: https://hosted.weblate.org/projects/amule/amule-application/ar/ Co-authored-by: Diego Heras <[email protected]> Co-authored-by: Got3nks <[email protected]> Co-authored-by: Hosted Weblate user 54392 <[email protected]> Co-authored-by: Marcelo Roberto Jimenez <[email protected]> Co-authored-by: mslr8 <[email protected]> Co-authored-by: தமிழ்நேரம் <[email protected]> Co-authored-by: ℂ𝕠𝕠𝕠𝕝 (𝕘𝕚𝕥𝕙𝕦𝕓.𝕔𝕠𝕞/ℂ𝕠𝕠𝕠𝕝) <[email protected]>
Follow-up to #677, reported by @danim7.
#677 fixed the libbfd path's PIE handling but left the no-libbfd fallback broken in exactly the same way: it shells out to
addr2line -e /proc/<pid>/exe <addrs>with raw runtime PCs, which addr2line can't resolve for PIE binaries. After uninstallingbinutils-dev, @danim7 confirmed amule frames came back as??-- same symptom as the pre-#677 bfd path.How
Hoist the
s_pie_baseplumbing (#include <link.h>,find_pie_base_cb, dl_iterate_phdr call) out of#ifdef HAVE_BFDinto the shared Linux scope. Wrap the lookup ininit_pie_base()(idempotent -- no-op on second call) so the bfd path'sinit_backtrace_info()and the no-bfd path ofget_backtrace()both seed it at the right moment without duplicating the dl_iterate_phdr call.In the no-bfd branch, build a
translatedAddressesstring by subtractings_pie_basefrom each runtime PC before formatting into the addr2line command line. PIE binaries get the link-time addresses addr2line expects. Non-PIE binaries haves_pie_base = 0(dlpi_addr is 0 for ET_EXEC) so the subtraction is a no-op and the addr2line invocation is byte-identical to before -- no regression possible on the non-PIE path.Verification
#ifdef __APPLE__, unaffected): clean build.Symmetric to #677. Both paths now use the same offset under the same conditions; either both work or both break on the same input.