Will Coleda wrote:
> 
> On Sep 10, 2007, at 12:47 AM, chromatic wrote:
> 
>> On Sunday 09 September 2007 21:40:56 Will Coleda via RT wrote:
>>
>>>
>>> Program received signal EXC_BAD_ACCESS, Could not access memory.
>>> Reason: KERN_INVALID_ADDRESS at address: 0xdeadbef3
>>> 0x00010b42 in clone_key_arg (interp=0x31003b0, st=0xbfffef3c) at
>>> src/inter_call.c:641 641         if (key && key->vtable->base_type ==
>>> enum_class_Key) {
>>
>> p key
>>
>> p key->vtable
>>
>> (my guess is the latter is 0xdeadbef3, which is really odd; collected
>> vtables
>> should be 0xdeadbeef).
>>
>> -- c
>>
> 
> I'd already done an svn up, now at r21171, still segfaulting:
> 
> (gdb) p key
> $1 = (PMC *) 0x1886030
> (gdb) p key->vtable
> $2 = (VTABLE *) 0xdeadbeef
> (gdb) p key->vtable->base_type
> Cannot access memory at address 0xdeadbef3
> 
> 
> 
> -- 
> Will "Coke" Coleda
> [EMAIL PROTECTED]
> 
> 
> 

Attached patch fixes the segfault for me. (And no memory leak too.) The
problem was that mark_context didn't mark ctx->caller_ctx, which is used
in get_params. Usually the caller context is accessible through
current_cont->to_ctx, but in a tail call it isn't, causing DOD to mark
registers in the context dead and setting their vtable to 0xdeadbeef,
causing the bug.

Cheers,
-- 
Bram Geron | GPG 0xE7B9E65E

diff --git a/src/sub.c b/src/sub.c
index bde6b3b..17461c4 100644
--- a/src/sub.c
+++ b/src/sub.c
@@ -58,6 +58,8 @@ mark_context(PARROT_INTERP, NOTNULL(parrot_context_t* ctx))
     obj = (PObj*)ctx->current_cont;
     if (obj && !PObj_live_TEST(obj))
         pobject_lives(interp, obj);
+    if (ctx->caller_ctx)
+        mark_context(interp, ctx->caller_ctx);
     obj = (PObj*)ctx->current_namespace;
     if (obj)
         pobject_lives(interp, obj);


Reply via email to