[m-dev.] for review: fix for a bug reported by Warwick

Warwick Harvey wharvey at cs.monash.edu.au
Tue Jan 25 19:55:06 AEDT 2000


Thanks heaps for working on this Zoltan.

> Warwick should test this out on his real test case, not just the cut-down
> one he sent me.

Unfortunately, it doesn't quite work.  It appears (at least in some cases) 
to restore the stack pointer and before testing the saved value of 
`MR_trace_from_full', which means it's looking in the wrong part of the 
stack, and hence sometimes making the wrong choice.

> Index: compiler/code_gen.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
> retrieving revision 1.71
> diff -u -b -r1.71 code_gen.m
> --- code_gen.m	1999/12/14 04:52:31	1.71
> +++ code_gen.m	2000/01/25 02:37:33
> @@ -409,7 +410,8 @@
>  			tree(ResumeCode,
>  			tree(TraceFailCode,
>  			tree(RestoreDeallocCode,
> -			     FailCode)))))))
> +			tree(UndoFillCode,
> +			     FailCode))))))))

Assuming I understand correctly, the UndoFillCode should come before the 
RestoreDeallocCode.

> @@ -771,7 +762,8 @@
>  			{ AllSuccessCode =
>  				tree(TraceExitCode,
>  				tree(RestoreDeallocCode,
> -				     SuccessCode))
> +				tree(SuccessUndoSlotFillCode,
> +				     SuccessCode)))

Ditto.

> @@ -784,7 +776,8 @@
>  			{ AllSuccessCode =
>  				tree(TraceExitCode,
>  				tree(RestoreDeallocCode,
> -				     SuccessCode))
> +				tree(SuccessUndoSlotFillCode,
> +				     SuccessCode)))

Ditto.

An example which exhibits the bug is std_util:type_of/2.  If the sample 
program I gave you still gives negative or decrementing numbers after the 
above fixes, one way to find predicates doing the wrong thing is by 
compiling with C debugging, firing up gdb, setting a watch on 
`MR_ticket_counter_var', and looking for those which decrement the counter 
without incrementing it first.

Warwick

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list