use strict; use warnings; use threads; use Carp qw(cluck); $Carp::Verbose = 1; use Inline 'C'; $SIG{__DIE__} = sub { cluck('someone died: ' . $_[0]); }; sub sub_that_dies { cluck('starting sub_that_dies'); sleep(2); die "something bad happened"; } sub start_thread { my ($arg) = @_; cluck('starting start_thread'); print "thread started: $arg\n"; if($arg == 1) { sub_that_dies(); } else { sub_that_core_dumps(); } } my $thr1 = threads->create('start_thread', 1); $thr1->join(); my $thr2 = threads->create('start_thread', 2); $thr2->join(); __END__ __C__ #include void sub_that_core_dumps() { printf("starting sub_that_core_dumps\n"); sleep(2); printf("sub_that_core_dumps awoke\n"); Inline_Stack_Vars; Inline_Stack_Push(newSVpvf("About to segfault in sub_that_core_dumps")); Inline_Stack_Done; perl_call_pv("Carp::cluck",0); memcpy(0,"source",1); Inline_Stack_Void; }