Segmentation fault when a try to catch a InterruptException


#1

Hi,

I have this code, I’m trying to catch a keyboard interrupt, but what a get it a segmentation fault

try
  for i in 1:10
    println(i)
    sleep(0.5)
  end
catch err
   if isa(err, InterruptException)
     exit() 
   end
   rethrow
end

Version 0.5.1-pre+55 (2017-02-13 09:11 UTC)
Commit 8d4ef37 (11 days old release-0.5)*
x86_64-linux-gnu

Regards.

Álvaro.


#2

As a note, it seems to work fine on the master branch.


#3

Also the rethrow line won’t actually throw anything and are you sure it’s actually an segfault?


#4

Yes it is a segfault, signal 11.

I’m recompiling everything

make cleanall
make

And still getting a segfault:

unknown function (ip: 0x40176d)
unknown function (ip: 0x401256)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x40129a)
unknown function (ip: 0xffffffffffffffff)
Allocations: 966693 (Pool: 965785; Big: 908); GC: 0

signal (11): Violación de segmento



#5

Hi again,

I delete all and install from master, and still get:

signal (2): Interrupción
while loading /home/x/test.jl, in expression starting on line 1
syscall at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
4
uv__epoll_wait at /home/x/src/julia/deps/srccache/libuv-52d72a52cc7ccd570929990f010ed16e2ec604c8/src/unix/linux-syscalls.c:321
uv__io_poll at /home/x/src/julia/deps/srccache/libuv-52d72a52cc7ccd570929990f010ed16e2ec604c8/src/unix/linux-core.c:267
uv_run at /home/x/src/julia/deps/srccache/libuv-52d72a52cc7ccd570929990f010ed16e2ec604c8/src/unix/core.c:354
process_events at ./libuv.jl:83
wait at ./event.jl:171
wait at ./event.jl:27
wait at ./event.jl:344
sleep at ./event.jl:385
macro expansion at /home/x/test.jl:4 [inlined]
anonymous at ./<missing> (unknown line)
jl_call_method_internal at /home/x/src/julia/src/julia_internal.h:248 [inlined]
jl_toplevel_eval_flex at /home/x/src/julia/src/toplevel.c:589
jl_parse_eval_all at /home/x/src/julia/src/ast.c:874
jl_load at /home/x/src/julia/src/toplevel.c:616
include_from_node1 at ./loading.jl:539
unknown function (ip: 0x7f72cc9b9e6b)
jl_call_method_internal at /home/x/src/julia/src/julia_internal.h:248 [inlined]
jl_apply_generic at /home/x/src/julia/src/gf.c:2212
include at ./sysimg.jl:14
unknown function (ip: 0x7f72cc87332b)
jl_call_method_internal at /home/x/src/julia/src/julia_internal.h:248 [inlined]
jl_apply_generic at /home/x/src/julia/src/gf.c:2212
process_options at ./client.jl:305
_start at ./client.jl:371
unknown function (ip: 0x7f72cc9e6478)
jl_call_method_internal at /home/x/src/julia/src/julia_internal.h:248 [inlined]
jl_apply_generic at /home/x/src/julia/src/gf.c:2212
unknown function (ip: 0x401cb1)
unknown function (ip: 0x401502)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4015a9)
unknown function (ip: 0xffffffffffffffff)
Allocations: 1091447 (Pool: 1090170; Big: 1277); GC: 0

Am I doing something wrong or it’s time to open a issue?

Thanks.

Álvaro.


#6

It seems that you are running from a script and this is the expected behavior. Note that this is not a segfault.


#7

Also note that in a script, you need to do ccall(:jl_exit_on_sigint, Void, (Cint,), 0) in order to turn a SIGINT into an exception. I have no idea why it is like this but it has been like this forever and doesn’t seem to be well documented…


#8

Yes, now in dev-0.6.0 doesn’t throw a segfault in 0.5.1 I still get a segfault.

Either way, I can’t catch the Interrupt exception with the script.

Update: The code works in the REPL.


#9

See my comment above.


#10

Sorry, I didn’t read it.

It works now.

Thank you.