opt crashes while running "CallGraph Pass Manager": Assertion `CallSites.empty() && "Dangling pointers found in call sites map"' failed
| Bugzilla Link | 31106 |
| Resolution | DUPLICATE |
| Resolved on | Jan 22, 2020 10:08 |
| Version | trunk |
| OS | All |
| Attachments | bitcode triggering the crash |
| CC | @chandlerc,@vns-mn,@ekatz,@filcab,@hfinkel |
Extended Description
$ clang -v clang version 4.0.0 (trunk 287325) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/local/clang-trunk/bin Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.4 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.2.0 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Candidate multilib: x32;@mx32 Selected multilib: .;@m64 $ $ clang -c -emit-llvm -o small.bc small.c $ opt -inline -loop-extract -o small-opt.bc small.bc opt: /tmp/llvm-builder/llvm-source-trunk/lib/Analysis/CallGraphSCCPass.cpp:352: bool {anonymous}::CGPassManager::RefreshCallGraph(const llvm::CallGraphSCC&, llvm::CallGraph&, bool): Assertion `CallSites.empty() && "Dangling pointers found in call sites map"' failed. #0 0x0000000001c3af05 (opt+0x1c3af05) #1 0x0000000001c38fee (opt+0x1c38fee) #2 0x0000000001c39150 (opt+0x1c39150) #3 0x00007febf8f5e330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330) #4 0x00007febf7d4ac37 gsignal /build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0 #5 0x00007febf7d4e028 abort /build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0 #6 0x00007febf7d43bf6 __assert_fail_base /build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0 #7 0x00007febf7d43ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2) #8 0x00000000012b0fd0 (opt+0x12b0fd0) #9 0x00000000012b1a7b (opt+0x12b1a7b) #10 0x00000000017d990a (opt+0x17d990a) #11 0x000000000078a6b1 (opt+0x78a6b1) #12 0x00007febf7d35f45 __libc_start_main /build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0 #13 0x00000000007e4336 (opt+0x7e4336) Stack dump: 0. Program arguments: opt -inline -loop-extract -o small-opt.bc small.bc
-
Running pass 'CallGraph Pass Manager' on module 'small.bc'.
Aborted (core dumped) $
int printf (const char *, ...);
int a;
void fn1 () { while (1) if (a < 1) break; }
int main () { fn1 (); while (a) printf ("%d\n", a); return 0; }
mentioned in issue llvm/llvm-project#9301
*** This bug has been marked as a duplicate of bug llvm/llvm-project#9301 ***
Fix in https://reviews.llvm.org/D69069
Is this pass ported to the new PM? and see if there is a problem there?
I don't think this was ported to the new pass manager yet. I'll take a stab at it tomorrow.
FWIW, I and Chandler discussed this on IRC and he's going to take a look once he's done with the basic invalidation stuffs for the new PM.
Is this pass ported to the new PM? and see if there is a problem there?
I don't think this was ported to the new pass manager yet. I'll take a stab at it tomorrow.
Is this pass ported to the new PM? and see if there is a problem there?
I think that a solution would be that of having code extractor updating the callgraph as it's actually clobbering it.
RefreshCallGraph as it's written only deals with function messing around with the callgraph, so given functions cannot access anything outside of themselves, I think the basic cases are covered (i.e. it's correct for what it's doing).
Here , I think, CodeExtractor is actually performing a non-trivial modification of the callgraph, so I'm not entirely sure this is RefreshCallGraph's fault.
This is particularly nasty because it would require CodeExtractor to access the SCCs of the CG when functions (or even loops!) can call it, so it's going to access an unit of IR larger than the one it's expecting to operate on, IMHO.
This one is interesting.
So, loop extract calls code extractor which transforms:
@patatino { [...] call @pat [...] }
(note that the call is in one of the blocks forming the loop)
into
@patatino { [...] call @patatino_while_cond() [...] }
@patatino_while_cond() { [...] call @pat [...] }
So, in the callgraph we had (caller-callee relation): patatino -> pat which becomes patatino -> patatino_while_cond() -> pat
RefreshCallGraph doesn't know about this case so we end up with a dangling pointer in the callsite map. CC:ing David for thought as he worked on CodeExtractor quite a bit recently.
Reduced:
define void @tinky(i1 %y) { entry: br label %while.body while.body: br i1 %y, label %if.then, label %if.then if.then: ret void }
define void @patatino(i1 %x) { entry: call void @tinky(i1 %x) br label %while.cond while.cond: call void @pat() br label %while.cond }
declare void @pat()
$ ./opt blah.ll -inline -loop-extract -o /dev/null opt: ../lib/Analysis/CallGraphSCCPass.cpp:353: bool {anonymous}::CGPassManager::RefreshCallGraph(const llvm::CallGraphSCC&, llvm::CallGraph&, bool): Assertion `CallSites.empty() && "Dangling pointers found in call sites map"' failed.
assigned to @ekatz