From 10744069fc84c488a4f58ad0f5f3996eb01623e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Manuel=20de=20Morais=20Santos=20Costa?= Date: Fri, 29 Jan 2010 18:09:07 +0000 Subject: [PATCH] fix global variable core dump in threaded yapor. --- C/grow.c | 27 ++++++++++++++++----------- C/tracer.c | 4 ---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/C/grow.c b/C/grow.c index db92dd39d..065451dc2 100644 --- a/C/grow.c +++ b/C/grow.c @@ -64,7 +64,7 @@ STATIC_PROTO(Int p_inform_stack_overflows, (void)); STATIC_PROTO(int growstack, (long)); STATIC_PROTO(void MoveGlobal, (void)); STATIC_PROTO(void MoveLocalAndTrail, (void)); -STATIC_PROTO(void SetHeapRegs, (void)); +STATIC_PROTO(void SetHeapRegs, (int)); STATIC_PROTO(void AdjustTrail, (int, int)); STATIC_PROTO(void AdjustLocal, (void)); STATIC_PROTO(void AdjustGlobal, (long)); @@ -111,7 +111,7 @@ cpcellsd(register CELL *Dest, register CELL *Org, CELL NOf) static void -SetHeapRegs(void) +SetHeapRegs(int copying_threads) { #ifdef undf7 fprintf(Yap_stderr,"HeapBase = %x\tHeapTop=%x\nGlobalBase=%x\tGlobalTop=%x\nLocalBase=%x\tLocatTop=%x\n", Yap_HeapBase, HeapTop, Yap_GlobalBase, H, LCL0, ASP); @@ -185,10 +185,12 @@ SetHeapRegs(void) S = PtoGloAdjust(S); else if (IsOldLocalPtr(S)) S = PtoLocAdjust(S); - if (GlobalArena) - GlobalArena = AbsAppl(PtoGloAdjust(RepAppl(GlobalArena))); - if (GlobalDelayArena) - GlobalDelayArena = GlobalAdjust(GlobalDelayArena); + if (!copying_threads) { + if (GlobalArena) + GlobalArena = AbsAppl(PtoGloAdjust(RepAppl(GlobalArena))); + if (GlobalDelayArena) + GlobalDelayArena = GlobalAdjust(GlobalDelayArena); + } #ifdef COROUTINING if (DelayedVars) DelayedVars = AbsAppl(PtoGloAdjust(RepAppl(DelayedVars))); @@ -306,7 +308,7 @@ AdjustPair(register CELL t0) } static void -AdjustTrail(int adjusting_heap, int duplicate_references) +AdjustTrail(int adjusting_heap, int thread_copying) { volatile tr_fr_ptr ptt; @@ -326,6 +328,9 @@ AdjustTrail(int adjusting_heap, int duplicate_references) TrailTerm(ptt) = GlobalAdjust(reg); else if (IsOldTrail(reg)) TrailTerm(ptt) = TrailAdjust(reg); + else if (thread_copying) { + RESET_VARIABLE(&TrailTerm(ptt)); + } } else if (IsPairTerm(reg)) { TrailTerm(ptt) = AdjustPair(reg); #ifdef MULTI_ASSIGNMENT_VARIABLES /* does not work with new structures */ @@ -682,7 +687,7 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o TrDiff = LDiff = GDiff = GDiff0 = DelayDiff = BaseDiff = size; XDiff = HDiff = 0; GSplit = NULL; - SetHeapRegs(); + SetHeapRegs(FALSE); MoveLocalAndTrail(); if (fix_code) { CELL *SaveOldH = OldH; @@ -860,7 +865,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit) GSplit = hsplit; XDiff = HDiff = 0; Yap_GlobalBase = old_GlobalBase; - SetHeapRegs(); + SetHeapRegs(FALSE); if (do_grow) { MoveLocalAndTrail(); if (hsplit) { @@ -1401,7 +1406,7 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp, } #endif ASP -= 256; - SetHeapRegs(); + SetHeapRegs(FALSE); if (from_trail) { Yap_TrailTop += size0; } @@ -1739,7 +1744,7 @@ Yap_CopyThreadStacks(int worker_q, int worker_p) DynamicArrays = NULL; StaticArrays = NULL; GlobalVariables = NULL; - SetHeapRegs(); + SetHeapRegs(TRUE); CopyLocalAndTrail(); MoveGlobal(); AdjustStacksAndTrail(0, TRUE); diff --git a/C/tracer.c b/C/tracer.c index f5d3b9aed..54e333105 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -172,10 +172,6 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) LOCK(Yap_heap_regs->low_level_trace_lock); sc = Yap_heap_regs; vsc_count++; - if (vsc_count < 637746000LL) - return; - if (vsc_count == 637746933LL) - jmp_deb(1); #ifdef THREADS Yap_heap_regs->thread_handle[worker_id].thread_inst_count++; #endif