Skip to content

segfault in lldb #176172

Closed as not planned
Closed as not planned
@ccreutzi

Description

@ccreutzi

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config
HOMEBREW_VERSION: 4.3.8
ORIGIN: https://github.com/Homebrew/brew
HEAD: e5f776b3e23cae8f1b6c3d1194b8329bf701965f
Last commit: 28 hours ago
Core tap JSON: 02 Jul 10:31 UTC
Core cask tap JSON: 02 Jul 10:31 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: emacs
HOMEBREW_MAKE_JOBS: 12
Homebrew Ruby: 3.3.3 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.3/bin/ruby
CPU: dodeca-core 64-bit arm_blizzard_avalanche
Clang: 15.0.0 build 1500
Git: 2.39.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.6.0 => /usr/bin/curl
macOS: 14.5-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: 15.1
Rosetta 2: false

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Your Xcode (15.1) is outdated.
Please update to Xcode 15.4 (or delete it).
Xcode can be updated from the App Store.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

Build https://github.com/podofo/podofo with homebrew's llvm and -fsanitize=undefined,address and then running lldb target/podofo-unit. Running target/podofo-unit outside the debugger shows UBSan output as follows:

$ target/podofo-unit 
podofo-unit(66249,0x1f6168c00) malloc: nano zone abandoned due to inability to reserve vm space.
/mathworks/devel/sandbox/ccreutzi/podofo/src/podofo/main/PdfIndirectObjectList.h:356:54: runtime error: reference binding to null pointer of type 'PdfDocument'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mathworks/devel/sandbox/ccreutzi/podofo/src/podofo/main/PdfIndirectObjectList.h:356:54 
/mathworks/devel/sandbox/ccreutzi/podofo/src/podofo/main/PdfParser.cpp:225:51: runtime error: reference binding to null pointer of type 'PdfDocument'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mathworks/devel/sandbox/ccreutzi/podofo/src/podofo/main/PdfParser.cpp:225:51 
/mathworks/devel/sandbox/ccreutzi/podofo/src/podofo/main/PdfFont.cpp:435:44: runtime error: nan is outside the range of representable values of type 'long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mathworks/devel/sandbox/ccreutzi/podofo/src/podofo/main/PdfFont.cpp:435:44 
/mathworks/devel/sandbox/ccreutzi/podofo/src/podofo/main/PdfFont.cpp:436:44: runtime error: nan is outside the range of representable values of type 'long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mathworks/devel/sandbox/ccreutzi/podofo/src/podofo/main/PdfFont.cpp:436:44 
...

What happened (include all command output)?

lldb crashes. It looks like this happens when it tries to print the stack trace of the first UBSan hit.

$ lldb target/podofo-unit 
(lldb) target create "target/podofo-unit"
Current executable set to '/mathworks/devel/sandbox/ccreutzi/podofo/build-maca64/target/podofo-unit' (arm64).
(lldb) r
Process 66846 launched: '/mathworks/devel/sandbox/ccreutzi/podofo/build-maca64/target/podofo-unit' (arm64)
podofo-unit(66846,0x1f6168c00) malloc: nano zone abandoned due to inability to reserve vm space.
(lldb) PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace.
 #0 0x00000001179e2a14 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0x166a14)
 #1 0x00000001179e097c llvm::sys::RunSignalHandlers() (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0x16497c)
 #2 0x00000001179e30d0 SignalHandler(int) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0x1670d0)
 #3 0x000000018e35f584 (/usr/lib/system/libsystem_platform.dylib+0x180477584)
 #4 0x0000000105fcacfc RetrieveUnsigned(std::__1::shared_ptr<lldb_private::ValueObject>, std::__1::shared_ptr<lldb_private::Process>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x5eacfc)
 #5 0x0000000105fcaba4 RetrieveString(std::__1::shared_ptr<lldb_private::ValueObject>, std::__1::shared_ptr<lldb_private::Process>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x5eaba4)
 #6 0x0000000105fc9f88 lldb_private::InstrumentationRuntimeUBSan::RetrieveReportData(lldb_private::ExecutionContextRef) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x5e9f88)
 #7 0x0000000105fcb120 lldb_private::InstrumentationRuntimeUBSan::NotifyBreakpointHit(void*, lldb_private::StoppointCallbackContext*, unsigned long long, unsigned long long) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x5eb120)
 #8 0x0000000105e80d94 lldb_private::StopInfoBreakpoint::PerformAction(lldb_private::Event*) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x4a0d94)
 #9 0x0000000105e4bdf8 lldb_private::Process::ProcessEventData::ShouldStop(lldb_private::Event*, bool&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x46bdf8)
#10 0x0000000105e4c138 lldb_private::Process::ProcessEventData::DoOnRemoval(lldb_private::Event*) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x46c138)
#11 0x0000000105ef10a8 lldb_private::Event::DoOnRemoval() (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x5110a8)
#12 0x0000000105ef661c lldb_private::Listener::FindNextEventInternal(std::__1::unique_lock<std::__1::mutex>&, lldb_private::Broadcaster*, unsigned int, std::__1::shared_ptr<lldb_private::Event>&, bool) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x51661c)
#13 0x0000000105ef6bfc lldb_private::Listener::GetEventInternal(lldb_private::Timeout<std::__1::ratio<1l, 1000000l>> const&, lldb_private::Broadcaster*, unsigned int, std::__1::shared_ptr<lldb_private::Event>&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x516bfc)
#14 0x0000000105c79ee8 lldb_private::Debugger::DefaultEventHandler() (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x299ee8)
#15 0x0000000105c7d150 std::__1::__function::__func<lldb_private::Debugger::StartEventHandlerThread()::$_4, std::__1::allocator<lldb_private::Debugger::StartEventHandlerThread()::$_4>, void* ()>::operator()() (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x29d150)
#16 0x0000000105d57ad4 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x377ad4)
#17 0x00000001063d30c0 lldb_private::HostThreadMacOSX::ThreadCreateTrampoline(void*) (/opt/homebrew/Cellar/llvm/18.1.8/lib/liblldb.18.1.8.dylib+0x9f30c0)
#18 0x000000018e32ef94 (/usr/lib/system/libsystem_pthread.dylib+0x180446f94)
#19 0x000000018e329d34 (/usr/lib/system/libsystem_pthread.dylib+0x180441d34)
LLDB diagnostics will be written to /var/folders/dj/5hz7_3850_b0yvz96r271mhh0005q9/T/diagnostics-d78ed8
Please include the directory content when filing a bug report
Segmentation fault: 11

What did you expect to happen?

I expected the debugger to stop at the UBSan violation.

Step-by-step reproduction instructions (by running brew commands)

brew install llvm
git clone [email protected]:podofo/podofo.git
cd podofo
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
  -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
  -DPODOFO_BUILD_TOOLS=true \
  -DCMAKE_CXX_FLAGS="-g3 -O0 -fsanitize=undefined,address -fno-omit-frame-pointer -Wl,-ld_classic" \
  ..
cmake --build . --config Debug -v -j
lldb target/podofo-unit

In lldb, run r.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugReproducible Homebrew/homebrew-core bugstaleNo recent activity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions