dvm-system / sapfor

SAPFOR (System FOR Automated Parallelization)
Apache License 2.0
6 stars 5 forks source link

volatile array crashes tsar #2

Open mishapankin opened 1 year ago

mishapankin commented 1 year ago

Проблема

Если в анализируемой программе есть запись в массив с ключевым словом volatile, то tsar падает.

Шаги для воспроизведения

  1. Создать файл volatile.c

    int main() {
    volatile int a[5];
    a[0] = 10;
    
    return 0;
    }
  2. Выполнить команду
    
    tsar volatile.c --print-all
# Ошибка

Printing analysis 'Array Access Delinearizer' for function 'main': {"Accesses":{" %1 = alloca [5 x i32], align 16":[[["0","0"]]]},"Sizes":{" %1 = alloca [5 x i32], align 16":["5"]},"IsDelinearized":1} Printing analysis 'Private Variable Analysis' for function 'main': Printing analysis 'Dependency Analysis (Metadata)' for function 'main': Printing analysis 'Not Initialized Memory Checker (Metadata)' for function 'main': Printing analysis 'Array Accesses Collector (Metadata, Wrapper)': Printing analysis 'High and Low Level Expression Matcher (Clang)' for function 'main': volatile.c:3:10 BinaryOperator '=' store volatile i32 10, ptr %2, align 16, !dbg !28, !tbaa !29 volatile.c:5:5 ReturnStmt ret i32 0, !dbg !34 Printing analysis 'Canonical Form Loop Analysis' for function 'main': Printing analysis 'nocapture': [NOCAPTURE] [main] tsar: /home/mishapankin/Work/sapfor/analyzers/tsar/lib/Analysis/Memory/DIEstimateMemory.cpp:2215: llvm::Optional tsar::buildDIMemory(const llvm::MemoryLocation&, llvm::LLVMContext&, const llvm::DataLayout&, const llvm::DominatorTree&): Assertion `LastDwarfOp == dwarf::DW_OP_plus_uconst && "Unknown DWARF operand!"' failed.

0 0x00005646cf7f13b1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0x23cc3b1)

1 0x00005646cf7ef0cc llvm::sys::RunSignalHandlers() (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0x23ca0cc)

2 0x00005646cf7f18db SignalHandler(int) Signals.cpp.o:0:0

3 0x00007f7eea642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)

4 0x00007f7eea696a7c __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76

5 0x00007f7eea696a7c __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10

6 0x00007f7eea696a7c pthread_kill ./nptl/./nptl/pthread_kill.c:89:10

7 0x00007f7eea642476 gsignal ./signal/../sysdeps/posix/raise.c:27:6

8 0x00007f7eea6287f3 abort ./stdlib/./stdlib/abort.c:81:7

9 0x00007f7eea62871b _nl_load_domain ./intl/./intl/loadmsgcat.c:1177:9

10 0x00007f7eea639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)

11 0x00005646d0fb3fb4 tsar::buildDIMemory(llvm::MemoryLocation const&, llvm::LLVMContext&, llvm::DataLayout const&, llvm::DominatorTree const&) /home/mishapankin/Work/sapfor/analyzers/tsar/lib/Analysis/Memory/DIEstimateMemory.cpp:2216:21

12 0x00005646d0fb4452 tsar::buildDIMemoryWithNewSize(tsar::EstimateMemory const&, llvm::LocationSize, llvm::LLVMContext&, tsar::DIMemoryEnvironment&, llvm::DataLayout const&, llvm::DominatorTree const&) /home/mishapankin/Work/sapfor/analyzers/tsar/lib/Analysis/Memory/DIEstimateMemory.cpp:2253:29

13 0x00005646d0fb434c tsar::buildDIMemory(tsar::EstimateMemory const&, llvm::LLVMContext&, tsar::DIMemoryEnvironment&, llvm::DataLayout const&, llvm::DominatorTree const&) /home/mishapankin/Work/sapfor/analyzers/tsar/lib/Analysis/Memory/DIEstimateMemory.cpp:2245:69

14 0x00005646d0fab0a2 (anonymous namespace)::buildDIAliasTree(llvm::DataLayout const&, llvm::DominatorTree const&, tsar::DIMemoryEnvironment&, llvm::DenseMap<llvm::Value const, long, llvm::DenseMapInfo<llvm::Value const, void>, llvm::detail::DenseMapPair<llvm::Value const, long> > const&, tsar::CorruptedMemoryResolver&, tsar::DIAliasTree&, tsar::AliasNode&, tsar::DIAliasNode&, llvm::DenseMap<tsar::CorruptedMemoryItem, tsar::DIAliasNode, llvm::DenseMapInfo<tsar::CorruptedMemoryItem, void>, llvm::detail::DenseMapPair<tsar::CorruptedMemoryItem, tsar::DIAliasNode> >&) /home/mishapankin/Work/sapfor/analyzers/tsar/lib/Analysis/Memory/DIEstimateMemory.cpp:865:79

15 0x00005646d0fb5e5a llvm::DIEstimateMemoryPass::runOnFunction(llvm::Function&) /home/mishapankin/Work/sapfor/analyzers/tsar/lib/Analysis/Memory/DIEstimateMemory.cpp:2471:21

16 0x00005646cf64b5d2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0x22265d2)

17 0x00005646d2637ce2 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) CallGraphSCCPass.cpp.o:0:0

18 0x00005646cf64c176 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0x2227176)

19 0x00005646ce11d85c tsar::DefaultQueryManager::run(llvm::Module, tsar::TransformationInfo) /home/mishapankin/Work/sapfor/analyzers/tsar/lib/Core/Query.cpp:365:1

20 0x00005646d0679a70 clang::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) /home/mishapankin/Work/sapfor/analyzers/tsar/lib/Frontend/Clang/Action.cpp:135:5

21 0x00005646ce5b3d4b clang::ParseAST(clang::Sema&, bool, bool) (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0x118ed4b)

22 0x00005646ce1f5417 clang::FrontendAction::Execute() (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0xdd0417)

23 0x00005646ce168036 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0xd43036)

24 0x00005646ce13983c clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr, clang::FileManager, std::shared_ptr, clang::DiagnosticConsumer) (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0xd1483c)

25 0x00005646ce13959f clang::tooling::ToolInvocation::runInvocation(char const, clang::driver::Compilation, std::shared_ptr, std::shared_ptr) (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0xd1459f)

26 0x00005646ce13850f clang::tooling::ToolInvocation::run() (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0xd1350f)

27 0x00005646ce13b02e clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0xd1602e)

28 0x00005646ce0db66c tsar::Tool::run(tsar::QueryManager*) /home/mishapankin/Work/sapfor/analyzers/tsar/lib/Core/Tool.cpp:844:16

29 0x00005646ce0d24a6 main /home/mishapankin/Work/sapfor/analyzers/tsar/tools/tsar/main.cpp:42:22

30 0x00007f7eea629d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16

31 0x00007f7eea629e40 call_init ./csu/../csu/libc-start.c:128:20

32 0x00007f7eea629e40 __libc_start_main ./csu/../csu/libc-start.c:379:5

33 0x00005646ce0d2325 _start (/home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar+0xcad325)

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump:

  1. Program arguments: /home/mishapankin/Work/sapfor/build/analyzers/tsar/bin/tsar volatile.c --print-all
  2. parser at end of file
  3. Running pass 'CallGraph Pass Manager' on module '/home/mishapankin/Work/sapfor/example/volatile.c'.
  4. Running pass 'Memory Estimator (Debug)' on function '@main'