Skip to content

lldb: Crash in RunCommandInterpreter When Using force_io_methods=True in Python API (Regression in LLDB 21) #170891

@patryk4815

Description

@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:
58279d1


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:

dnf install lldb -y

Minimal Reproduction

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

Image

stdout and stderr is null, crash SIGSEGV

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]lldb

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions