[m-dev.] debugger seg faults

Tyson Dowd trd at cs.mu.OZ.AU
Fri Nov 6 14:34:10 AEDT 1998


On 06-Nov-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> The debugger gets a segmentation violation for e.g. tests/debugger/queens
> in grade `reg' on murlibobo.
> 
> The bug is a memory management bug.
> The debugger (trace/*.c) allocates memory in two ways:
> 
> 	(1) by calling incr_saved_hp() in MR_create_type_info() and elsewhere
> 
> 	(2) by calling Mercury routines defined in browser or library
> 	    that allocate memory, e.g. io__print
> 
> Method (1) allocates using the hp (unless the hp register is transient, in
> which case it uses the fake_reg copy, but that's not the case on alphas).
> 
> Method (2) ends up allocating using the saved copy of the hp in fake_reg,
> since when we call Mercury code from C, the stub created by `pragma export'
> calls restore_registers(), then call_engine() to invoke the Mercury code,
> and the save_regsters() again.
> 
> The hp and the saved copy of it in fake_reg start out the same,
> so when we allocate some memory using method (1) and then allocate
> some more using method (2), the second allocation overwrites the first.
> 
> I'm not sure yet what the best fix is.

Zoltan suggests that we really need more versions of MR_create_type_info
to handle different memory allocation strategies.  The best way to do
this is to make it like deep_copy -- a function that is #defined
in various ways to do different memory allocations.

I am willing to work on this.

-- 

Because I dislike being quoted I lie almost constantly when talking 
about my work.
		-- Terry Gilliam

Tyson Dowd   <tyson at tyse.net>   http://tyse.net/tyson 




More information about the developers mailing list