[m-dev.] a bug in the declarative debugger

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jun 3 22:10:52 AEST 1999


Hi,

The test case tests/debugger/declarative/app fails in grade asm_fast on hydra.
The symptom is that it gets a seg fault. 

After a couple of hours of debugging, I tracked it down to a memory
management problem.  The problem is that 

	MR_trace_decl_wrong_answer() calls
	MR_trace_decl_wrong_answer_exit() which calls
	MR_trace_decl_save_args() which calls
	MR_get_type_and_value_base() which calls
	MR_create_type_info()

which allocates the type_infos on the Mercury heap.  This means that
the type_infos will be subsequently deallocated on backtracking.
But MR_trace_decl_save_args() stores shallow copies of them in the
EDT node that MR_trace_decl_wrong_answer_exit() inserts into the EDT tree.
Once the type_infos are deallocated on backtracking, these shallow copies
become dangling pointers; later allocation overwrites the values that they
point to, and this leads to a crash.

Mark, could you please fix this one?  If it is going to take much time,
then please disable the `app' test in the meantime.

One possible fix is to call MR_make_permanent()
[or MR_make_long_lived(), with the value of the hp limit being the
value of hp in MR_trace_start_wrong_answer()]
on each of the type_infos returned from MR_get_type_and_value_base(),
to copy them from the Mercury heap to the Mercury global heap,
so that they won't be deallocated on backtracking.

Cheers,
	Fergus.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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