Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault when profiling #2217

Closed
langston-barrett opened this issue Mar 15, 2022 · 4 comments · Fixed by #2226
Closed

segfault when profiling #2217

langston-barrett opened this issue Mar 15, 2022 · 4 comments · Fixed by #2226
Labels
bug - identified Bugs with an identified cause

Comments

@langston-barrett
Copy link
Contributor

Souffle version: fce85d9

Command-line:

Starting program: /usr/local/bin/souffle -PSIPS:max-bound -j 24 -L .out/build/llvm -lFunctors llvm/PointerAnalysis/datalog/unification.project -F .out/cache/pointer-analysis/out.ll.facts -D .out/cache/pointer-analysis/out.ll.results -p prof.json

GDB backtrace:

Thread 1 "souffle" received signal SIGSEGV, Segmentation fault.
souffle::ProfileEventSingleton::dump (this=0x0)
    at ../src/include/souffle/profile/ProfileEvent.h:133
133	../src/include/souffle/profile/ProfileEvent.h: No such file or directory.
(gdb) bt
#0  souffle::ProfileEventSingleton::dump (this=0x0)
    at ../src/include/souffle/profile/ProfileEvent.h:133
#1  0x0000000000512009 in souffle::ProfileEventSingleton::~ProfileEventSingleton (
    this=0x234fa60) at ../src/include/souffle/profile/ProfileEvent.h:54
#2  0x0000000000511e58 in std::__1::default_delete<souffle::ProfileEventSingleton>::operator() (__ptr=0x234fa60, this=<optimized out>)
    at /usr/lib/llvm-10/bin/../include/c++/v1/memory:2363
#3  std::__1::unique_ptr<souffle::ProfileEventSingleton, std::__1::default_delete<souffle::ProfileEventSingleton> >::reset (this=<optimized out>, __p=0x0)
    at /usr/lib/llvm-10/bin/../include/c++/v1/memory:2618
#4  std::__1::unique_ptr<souffle::ProfileEventSingleton, std::__1::default_delete<souffle::ProfileEventSingleton> >::~unique_ptr (this=<optimized out>)
    at /usr/lib/llvm-10/bin/../include/c++/v1/memory:2572
#5  0x00007fa12bddfa27 in __run_exit_handlers (status=0, 
    listp=0x7fa12bf81718 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, 
    run_dtors=run_dtors@entry=true) at exit.c:108
#6  0x00007fa12bddfbe0 in __GI_exit (status=<optimized out>) at exit.c:139
#7  0x00007fa12bdbd0ba in __libc_start_main (main=0x4c2de0 <main(int, char**)>, argc=14, 
    argv=0x7ffea0324318, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7ffea0324308) at ../csu/libc-start.c:342
#8  0x00000000004b554e in _start ()

Let me know if there's anything else I could post that would help - my program is quite large and I haven't taken the time to minimize it yet, but I'm happy to send it on over.

@langston-barrett
Copy link
Contributor Author

langston-barrett commented Mar 15, 2022

Here's what ASan has to say about the same thing on commit d1522e0:

==11==ERROR: AddressSanitizer: UNKNOWN SIGNAL on unknown address 0x000200000002 (pc 0x00000097c54a bp 0x7ffc568715c0 sp 0x7ffc56871260 T0)
    #0 0x97c54a in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__is_long() const /usr/lib/llvm-10/bin/../include/c++/v1/string:1420:39
    #1 0x97c54a in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::size() const /usr/lib/llvm-10/bin/../include/c++/v1/string:947:17
    #2 0x97c54a in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::empty() const /usr/lib/llvm-10/bin/../include/c++/v1/string:967:42
    #3 0x97c54a in souffle::ProfileEventSingleton::dump() /mate/build/../src/include/souffle/profile/ProfileEvent.h:133:23
    #4 0x97c305 in souffle::ProfileEventSingleton::~ProfileEventSingleton() /mate/build/../src/include/souffle/profile/ProfileEvent.h:54:43
    #5 0x97bd90 in std::__1::default_delete<souffle::ProfileEventSingleton>::operator()(souffle::ProfileEventSingleton*) const /usr/lib/llvm-10/bin/../include/c++/v1/memory:2363:5
    #6 0x97bd90 in std::__1::unique_ptr<souffle::ProfileEventSingleton, std::__1::default_delete<souffle::ProfileEventSingleton> >::reset(souffle::ProfileEventSingleton*) /usr/lib/llvm-10/bin/../include/c++/v1/memory:2618:7
    #7 0x97bd90 in std::__1::unique_ptr<souffle::ProfileEventSingleton, std::__1::default_delete<souffle::ProfileEventSingleton> >::~unique_ptr() /usr/lib/llvm-10/bin/../include/c++/v1/memory:2572:19
    #8 0x7fe45a676a26 in __run_exit_handlers /build/glibc-eX1tMB/glibc-2.31/stdlib/exit.c:108:8
    #9 0x7fe45a676bdf in exit /build/glibc-eX1tMB/glibc-2.31/stdlib/exit.c:139:3
    #10 0x7fe45a6540b9 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
    #11 0x798e4d in _start (/mate/souffle/build/src/souffle+0x798e4d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: UNKNOWN SIGNAL /usr/lib/llvm-10/bin/../include/c++/v1/string:1420:39 in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__is_long() const
==11==ABORTING

@b-scholz
Copy link
Member

That is very strange; the singleton is a null pointer in the deconstruction of the singleton.
It looks like it was released before. Can you simplify your test case?
Also, are you running Souffle in isolation or are you using Souffle generated code as a library? Destruction of library objects can be sometimes problematic.

@b-scholz b-scholz added the bug - triage Bugs with unknown causes that require further investigation label Mar 17, 2022
@langston-barrett
Copy link
Contributor Author

Can you simplify your test case?

Apologies, I should have at least attempted this before posting the issue. It looks like it happens when you profile with any program whatsoever:

.decl x(n: number)
x(0).
.output x
$ souffle empty.dl -p prof.json
Segmentation fault (core dumped)

Also, are you running Souffle in isolation or are you using Souffle generated code as a library? Destruction of library objects can be sometimes problematic.

Normally, we use Souffle generated C++ as a library, however the above simplification shows this bug to be present in the interpreter as well.

@b-scholz
Copy link
Member

b-scholz commented Apr 2, 2022

I can reproduce the small test-case

.decl x(n: number)
x(0).
.output x

@b-scholz b-scholz added bug - identified Bugs with an identified cause and removed bug - triage Bugs with unknown causes that require further investigation labels Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - identified Bugs with an identified cause
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants