Issue 170891
Summary lldb: Crash in `RunCommandInterpreter` When Using `force_io_methods=True` in Python API (Regression in LLDB 21)
Labels new issue
Assignees
Reporter patryk4815
    Starting with **LLDB 21**, calling `RunCommandInterpreter` crashes when
the debugger's output and error streams are initialized using
`lldb.SBFile.Create(..., force_io_methods=True)` in Python.

The same code works correctly on **LLDB 20**.

Removing `force_io_methods=True` (or explicitly setting it to `False`)
avoids the crash, indicating a regression in LLDB's handling of `SBFile`
IO redirection.

Probably regression is introduced by:\
https://github.com/llvm/llvm-project/commit/58279d1ee1b567e8ca793d6d1eb6e0f1d5e7279e

------------------------------------------------------------------------

## Affected Versions

-   **LLDB 20** -- OK
-   **LLDB 21** -- **CRASH** when invoking `RunCommandInterpreter`

Tested on: 
- **Fedora 42** (lldb-20) --- works 
- **Fedora 43** (lldb-21) --- crashes

Install using:
```bash 
dnf install lldb -y
```

------------------------------------------------------------------------

## Minimal Reproduction

``` python
import lldb
import sys

lldb.SBDebugger.Initialize()
debugger = lldb.SBDebugger.Create()

debugger.SetOutputFile(lldb.SBFile.Create(sys.stdout, borrow=True, force_io_methods=True))
debugger.SetErrorFile(lldb.SBFile.Create(sys.stderr, borrow=True, force_io_methods=True))

# CRASHES on LLDB 21
debugger.RunCommandInterpreter(
    True, False,
 lldb.SBCommandInterpreterRunOptions(),
    0, False, False
)
```

### Notes

-   If `force_io_methods=True` is removed or set to `False`, **no crash occurs**.
-   The crash happens immediately upon entering `RunCommandInterpreter`.

------------------------------------------------------------------------

## Expected Behavior

`RunCommandInterpreter` should run normally, as it does in LLDB 20.

------------------------------------------------------------------------

## Additional context

<img width="940" height="890" alt="Image" src="" />

`stdout` and `stderr` is null, crash SIGSEGV

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to