NULL deference in real_exception

1 view
Skip to first unread message

Nicholas Clark

unread,
Apr 28, 2005, 4:48:11 AM4/28/05
to perl6-i...@perl.org
In exceptions.c, real_exception has:

{
STRING *msg;
Parrot_exception *the_exception = interpreter->exceptions;

...

/*
* FIXME classify errors
*/
the_exception->severity = EXCEPT_error;

which goes BOOM:

Program received signal EXC_BAD_ACCESS, Could not access memory.
0x002406ac in real_exception (interpreter=0xe00150, ret_addr=0x0, exitcode=74, format=0x456f58 "%s() not implemented in class '%s'") at src/exceptions.c:691
691 the_exception->severity = EXCEPT_error;
(gdb) where
#0 0x002406ac in real_exception (interpreter=0xe00150, ret_addr=0x0, exitcode=74, format=0x456f58 "%s() not implemented in class '%s'") at src/exceptions.c:691
#1 0x003e38e8 in cant_do_method (interpreter=0xe00150, pmc=0x1016070, methname=0x44f4b4 "morph") at classes/default.pmc:57
#2 0x003e3e1c in Parrot_default_morph (interpreter=0xe00150, pmc=0x1016070, type=88) at default.c:212
#3 0x00427100 in Parrot_Perl5cargo_cult_set_integer_keyed_int (interpreter=0xe00150, pmc=0x1016070, key=2, value=4) at perl5cargo_cult.pmc:1124
#4 0x001d5c80 in Parrot_PMC_set_intval_intkey (interp=0xe00150, pmc=0x1016070, key=2, value=4) at src/extend.c:453
#5 0x000b6378 in Perl_sv_upgrade (sv=0xfefe9f8f, mt=4) at sv.c:1808
#6 0x000c630c in Perl_newSV (len=79) at sv.c:5083
#7 0x0001ff7c in perl_construct (my_perl=0xe00140) at perl.c:287
#8 0x00002784 in main (argc=1, argv=0xbffff730, env=0xbffff738) at miniperlmain.c:93

because

(gdb) p interpreter->exceptions
$5 = (struct parrot_exception_t *) 0x0


what should have initialised that?

Nicholas Clark

Leopold Toetsch

unread,
Apr 28, 2005, 8:14:17 AM4/28/05
to Nicholas Clark, perl6-i...@perl.org
Nicholas Clark <ni...@ccl4.org> wrote:

> (gdb) p interpreter->exceptions
> $5 = (struct parrot_exception_t *) 0x0

> what should have initialised that?

An exception structure is created per entering a run-loop, see:
src/inter_runc.c:runops(). You can either create your own exception
setup/handler (which needs an interface) or probably simpler (and
proposed some time ago) use Parrot_run_native() to start your C code.

With the latter you'd have:

perl parrot

perl_init()
interp = Parrot_new()
...
Parrot_run_native(interp, perl_run) -->
runops()
enternative perl_run
<--

perl_run() { ... }

This would also set the stack top for GC.

see also t/src/*.t.

> Nicholas Clark

leo

Nicholas Clark

unread,
May 9, 2005, 1:19:35 PM5/9/05
to Leopold Toetsch, perl6-i...@perl.org

At this point I don't want to set the stack top for GC (at least not
including the stack that holds perl 5 function calls), as I'm trying to track
down all the causes of reference count anomalies in the perl core.

I've already found 1 bug (and fixed it):

http://public.activestate.com/cgi-bin/perlbrowse?patch=24410

and I think that I may have another long standing bug w.r.t. when global
destruction of the symbol table actually happens.

Nicholas Clark

Reply all
Reply to author
Forward
0 new messages