[m-rev.] for review: nondet stack tracing bug fix

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Dec 30 20:55:29 AEDT 2003


For review by zs.

Estimated hours taken: 4
Branches: main

A bug fix for accurate GC.

runtime/mercury_stack_trace.c:
	In MR_init_nondet_branch_infos(), skip past any deterministic
	frames until we find the first nondet frame (if any).

Workspace: /home/jupiter/fjh/ws-jupiter/mercury
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.59
diff -u -d -r1.59 mercury_stack_trace.c
--- runtime/mercury_stack_trace.c	18 Nov 2003 07:02:28 -0000	1.59
+++ runtime/mercury_stack_trace.c	30 Dec 2003 01:53:06 -0000
@@ -596,14 +596,44 @@
 MR_init_nondet_branch_infos(MR_Word *base_maxfr,
 	const MR_Label_Layout *top_layout, MR_Word *base_sp, MR_Word *base_curfr)
 {
+    const MR_Label_Layout *label_layout = top_layout;
+    MR_Word *stack_pointer = base_sp;
+    MR_Word *current_frame = base_curfr;
+
     MR_nondet_branch_info_next = 0;
-    MR_ensure_room_for_next(MR_nondet_branch_info, MR_Nondet_Branch_Info,
-            MR_INIT_NONDET_BRANCH_ARRAY_SIZE);
-    MR_nondet_branch_infos[0].branch_sp = base_sp;
-    MR_nondet_branch_infos[0].branch_curfr = base_curfr;
-    MR_nondet_branch_infos[0].branch_layout = top_layout;
-    MR_nondet_branch_infos[0].branch_topfr = base_curfr;
-    MR_nondet_branch_info_next++;
+
+    /*
+    ** Skip past any model_det frames.
+    */
+    do {
+        const MR_Proc_Layout            *proc_layout;
+        MR_Stack_Walk_Step_Result       result;
+        const char                      *problem;
+
+        proc_layout = label_layout->MR_sll_entry;
+        if (!MR_DETISM_DET_STACK(proc_layout->MR_sle_detism)) {
+            break;
+        }
+        result = MR_stack_walk_step(proc_layout, &label_layout,
+            &stack_pointer, &current_frame, &problem);
+        if (result == MR_STEP_ERROR_BEFORE || result == MR_STEP_ERROR_AFTER) {
+            MR_fatal_error(problem);
+        } 
+
+    } while (label_layout != NULL);
+
+    /* double-check that we didn't skip any model_non frames */
+    assert(current_frame == base_curfr);
+
+    if (label_layout != NULL) {
+        MR_ensure_room_for_next(MR_nondet_branch_info, MR_Nondet_Branch_Info,
+                MR_INIT_NONDET_BRANCH_ARRAY_SIZE);
+        MR_nondet_branch_infos[0].branch_sp = stack_pointer;
+        MR_nondet_branch_infos[0].branch_curfr = current_frame;
+        MR_nondet_branch_infos[0].branch_layout = label_layout;
+        MR_nondet_branch_infos[0].branch_topfr = base_curfr;
+        MR_nondet_branch_info_next++;
+    }
 }
 
 static const char *

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list