This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Show sub type of memory tagging SEGV when reading a core file
AbandonedPublic

Authored by DavidSpickett on Mar 6 2023, 6:26 AM.

Details

Reviewers
labath
omjavaid
Summary

Previously we only looked at the si_signo field, so you got:

(lldb) bt
* thread #1, name = 'a.out.mte', stop reason = signal SIGSEGV
  * frame #0: 0x00000000004007f4

This patch adds si_code so we can show:

(lldb) bt
* thread #1, name = 'a.out.mte', stop reason = signal SIGSEGV: sync tag check fault
  * frame #0: 0x00000000004007f4

The format matches that generated by Plugins/Process/POSIX/CrashReason,
which is used in native code. However we do not include the fault address
because (at least on Linux) the corefile doesn't include it.

The order of errno and code was incorrect in ElfLinuxSigInfo::Parse.
It was the order that a "swapped" siginfo arch would use, which for Linux,
is only MIPS. We removed MIPS Linux support some time ago.

See:
https://github.com/torvalds/linux/blob/fe15c26ee26efa11741a7b632e9f23b01aca4cc6/include/uapi/asm-generic/siginfo.h#L121

I've only added the two memory tagging fault types so far but
this can be expanded to any signal easily.

Diff Detail

Event Timeline

DavidSpickett created this revision.Mar 6 2023, 6:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 6:26 AM
DavidSpickett requested review of this revision.Mar 6 2023, 6:26 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 6 2023, 6:26 AM
DavidSpickett retitled this revision from [LLDB] Show sub type of faults for ELF core files to [LLDB] Show sub type of signals for ELF core files.Mar 6 2023, 6:26 AM
labath added inline comments.Mar 6 2023, 6:43 AM
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
227

I think this won't work on Windows (no siginfo_t type, nor constants to decode it) -- and it may return garbage on other platforms if they use different constants.

If I may suggest an alternative implementation:

  • Implement ThreadElfCore::GetSiginfo to return (verbatim) copy of the siginfo_t from the core file
  • Implement a generic stop info description calculation (on platform class) function

Besides the stop description, this should also make the thread siginfo command work, and we can consider removing the lldb-server-based stop info computation logic, since this impl should cover both live and post-portem use cases.

DavidSpickett planned changes to this revision.Mar 6 2023, 7:02 AM
DavidSpickett added inline comments.
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
227

Yes, of course.

I'll try what you suggested.

Add code functionality to UnixSignals instead.

DavidSpickett retitled this revision from [LLDB] Show sub type of signals for ELF core files to [LLDB] Show sub type of memory tagging SEGV when reading a core file.Mar 8 2023, 2:12 AM
DavidSpickett edited the summary of this revision. (Show Details)

This should build anywhere now.

I looked at thread siginfo and I see what you mean, but it'll take me some time to confirm exactly how much of siginfo is in the core file. I did get it to work using the full type, but I'm pretty sure some of the values were invalid.

Now I'm looking at replacing the CrashReason code with UnixSignals. Perhaps it can learn to append fault addresses and bounds.

DavidSpickett added inline comments.Mar 9 2023, 1:34 AM
lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
32
DavidSpickett planned changes to this revision.Mar 13 2023, 9:00 AM

I'm working on merging CrashReason into UnixSignals, so this will either be part of, or on top of that.

DavidSpickett abandoned this revision.Mar 14 2023, 5:39 AM

This will be back as part of a series.