brenhinkeller / StaticTools.jl

Enabling StaticCompiler.jl-based compilation of (some) Julia code to standalone native binaries by avoiding GC allocations and llvmcall-ing all the things!
MIT License
167 stars 11 forks source link

PkgEval: segfault during fclose #24

Closed maleadt closed 1 year ago

maleadt commented 1 year ago

As encountered on PkgEval:

ERROR: File does not exist!
[35] signal (11): Segmentation fault
in expression starting at /home/pkgeval/.julia/packages/StaticMPI/EzNpR/test/runtests.jl:5
fclose at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7fff351b85af)
Allocations: 3203825 (Pool: 3200007; Big: 3818); GC: 5

Traced back to the fclose from StaticTools.jl, and seems caused by passing a null handle to it:

ERROR: File does not exist!
Thread 1 hit Breakpoint 5, 0x00007f3db0b227e0 in fclose () from target:/lib/x86_64-linux-gnu/libc.so.6
(rr) bt
#0  0x00007f3db0b227e0 in fclose () from target:/lib/x86_64-linux-gnu/libc.so.6
#1  0x00007f3d94748259 in ?? ()
#2  0x00007fff351b85e0 in ?? ()
#3  0x0000000000000000 in ?? ()
(rr) p $rdi
$10 = 0

According to the man page:

 The behaviour of fclose() is undefined if the stream parameter is an illegal pointer, or is a descriptor already passed to a previous invocation of fclose().   
brenhinkeller commented 1 year ago

Ah ok, we can probably add a check for that