[Bug 51446] New: LLDB import std module tests crash with segmentation fault

Bug ID 51446
Summary LLDB import std module tests crash with segmentation fault
Product lldb
Version 12.0
Hardware PC
OS Linux
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter omair.javaid@linaro.org
CC jdevlieghere@apple.com, llvm-bugs@lists.llvm.org

This came up during release testing on x86_64 and AArch64 but reproducible with
tot.

** Build instructions:

CC=/home/omair.javaid/work/lldb-dev/clang+llvm-11.0.1-aarch64-linux-gnu/bin/clang
CXX=/home/omair.javaid/work/lldb-dev/clang+llvm-11.0.1-aarch64-linux-gnu/bin/clang++

cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="llvm;clang;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind;test-suite;openmp;lld;lldb;polly;mlir;flang"
\
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_LIT_ARGS=-svj4 \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
$LLDB_HOME/llvm-project/llvm

ninja

ninja check-lldb

** Failures:
  lldb-api ::
commands/expression/import-std-module/array/TestArrayFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/basic/TestImportStdModule.py
  lldb-api ::
commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py
  lldb-api ::
commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/iterator/TestIteratorFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/list/TestListFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
  lldb-api ::
commands/expression/import-std-module/queue/TestQueueFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py
  lldb-api ::
commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
  lldb-api ::
commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/vector/TestVectorFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
  lldb-api ::
commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py

** Example Errors:

Fatal Python error: Segmentation fault

Thread 0x0000ffffa8055010 (most recent call first):
  File
"/home/omair.javaid/work/lldb-dev/build/release/aarch64/lib/python3/dist-packages/lldb/__init__.py",
line 6002 in EvaluateExpression
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
line 2586 in expect_expr
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py",
line 28 in test
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
line 149 in wrapper
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
line 1834 in test_method
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/case.py",
line 413 in runMethod
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/case.py",
line 383 in run
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/case.py",
line 458 in __call__
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
line 117 in _wrapped_run
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
line 115 in _wrapped_run
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
line 85 in run
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
line 66 in __call__
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/runner.py",
line 165 in run
  File
"/home/omair.javaid/work/lldb-dev/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py",
line 1017 in run_suite
  File "/home/omair.javaid/work/lldb-dev/llvm-project/lldb/test/API/dotest.py",
line 7 in <module>

** Further comments:

I did a bit of investigation and found that crash emerges from
clang/lib/Parse/ParseAST.cpp
in clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) function.

Its called from
lldb/source/Plugin/ExpressionParser/Clang/ClangExpressionParser.cpp in function
ClangExpressionParser::ParseInternal at line no  1179  
ParseAST(m_compiler->getSema(), false, false);