Skip to content

Commit 73b2d67

Browse files
committed
[lldb][FreeBSD] Fix crash when execve fails with asserts enabled
535da10 introduced a check, when execve fails, to see if we are allowed to trace programs at all. Unfortunately because we like to call Status vars "error" and "status" in various combinations, one got misnamed. This lead to lldb-server trying to make an error value out of a success value when you did the following: ``` $ ./bin/lldb-server gdbserver 127.0.0.1:1234 -- is_not_a_file Assertion failed: (Err && "Cannot create Expected<T> from Error success value."), function Expected... ``` This happened because the execve fails, but the check whether we can trace says yes we can trace, but then we use the Status from the check to create the return value. That Status is in fact a success value not the failed Status we got from the execve attempt. With the name corrected you now get: ``` $ ./bin/lldb-server gdbserver 127.0.0.1:1234 -- is_not_a_file error: failed to launch 'is_not_a_file': execve failed: No such file or directory ``` Which is what we expect to see. This also fixes the test `TestGDBRemoteLaunch.py` when asserts are enabled.
1 parent 60d7bf3 commit 73b2d67

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo &launch_info,
7676
.GetProcessId();
7777
LLDB_LOG(log, "pid = {0:x}", pid);
7878
if (status.Fail()) {
79-
auto error = CanTrace();
8079
LLDB_LOG(log, "failed to launch process: {0}", status);
81-
if (status.Fail())
80+
auto error = CanTrace();
81+
if (error.Fail())
8282
return error.ToError();
8383
return status.ToError();
8484
}

0 commit comments

Comments
 (0)