Skip to content

unfriendly error message when debugee does not start correctly #48067

@emaste

Description

@emaste
Bugzilla Link 48723
Version unspecified
OS All
CC @JDevlieghere,@sylvestre

Extended Description

On FreeBSD, and I assume other operating systems, there are cases where the debugged application does not start correctly.

One recent case occurred on FreeBSD with W^X enabled (sysctl kern.elf64.allow_wx=0) and an attempt to execute a binary that requested an executable stack. Because W^X disallows mappings with simultaneous W & X protections the initial stack cannot be created and the kernel image activator reports SIGABRT from the target.

Similar cases occurred when attempting to execute a binary with a .text segment larger than a kernel limit.

The failure reported by LLDB in this case is not particularly clear:

$ lldb ./exec-stack
(lldb) target create "./exec-stack"
Current executable set to
'/home/emaste/src/freebsd-git/main/exec-stack' (x86_64).
(lldb) run
error: 'A' packet returned an error: 8

The old in-process target plugin handled this even more poorly:

(lldb) run
Assertion failed: (WIFSTOPPED(status) && wpid == (::pid_t)pid &&
"Could not sync with inferior process."), function Launch, file
/usr/home/emaste/src/freebsd-git/head/contrib/llvm-project/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp,
line 930.
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and
include the crash backtrace.
#​0 0x0000000004444ade PrintStackTrace
/usr/home/emaste/src/freebsd-git/head/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:13
#​1 0x0000000004442e11 RunSignalHandlers
/usr/home/emaste/src/freebsd-git/head/contrib/llvm-project/llvm/lib/Support/Signals.cpp:69:18
#​2 0x0000000004445335 SignalHandler
/usr/home/emaste/src/freebsd-git/head/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
#​3 0x0000000805299b20 handle_signal
/usr/home/emaste/src/freebsd-git/head/lib/libthr/thread/thr_sig.c:0:3
Abort trap (core dumped)

Although a relatively minor issue it would be nice to have an error message along the lines of "Unable to start inferior process" or such. Taking this to root cause would likely require finding a log message in the kernel log.

(For reference, the FreeBSD code review that prompted this investigation: https://reviews.freebsd.org/D28050)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillalldb

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions