darling
darling copied to clipboard
`Terminated due to signal 5` when debugging an app that uses `execve`
Expected Result The program should continue to execute.
Actual Result The program stops with signal 5
Steps To Reproduce
- Compile and run this code:
__attribute__((noinline))
int IsDebuggerPresent()
{
return 0;
}
int main(int argc, char** argv, char** envp)
{
std::cerr << "Debugger PID: " << getpid() << "\r\n" << std::flush;
while (!IsDebuggerPresent())
{
continue;
}
std::cerr << "Debugger attached." << "\r\n" << std::flush;
#define NAME "/usr/local/share/vsdbg/vsdbg"
char** argv1 = new char*[argc + 1];
memcpy(argv1, argv, sizeof(char*) * argc);
argv1[0] = NAME;
argv1[argc] = nullptr;
execve(NAME, argv1, envp);
}
- Attach
lldb, specifically the one provided on the Darling docs page. - Break in
IsDebuggerPresentfunction, step out of it, modify the value ofraxto a nonzero value so that the program can break out of the while loop. - Break again at
execve, step all the way until the nextlinux_syscall. The program should terminate there.
dmesg Output
Run dmesg | grep 'overlay\|darling'
[ 4422.536499] Darling TID 480 (PID 480) says: darling_sigexc_self()
System Information What system are you using?
| Software | Version |
|---|---|
| Linux Kernel | 5.10.60.1-microsoft-standard-WSL2+ |
| Darling | 289628cccf0cd7567c1d275f09600ad214d26acd |
It is failing here: https://github.com/darlinghq/darling/blob/289628cccf0cd7567c1d275f09600ad214d26acd/src/kernel/emulation/linux/process/execve.c#L131