Mercury Bugs - mercury
View Issue Details
0000065mercuryBugpublic2008-07-03 15:222008-08-07 11:20
Reporterwangp 
Assigned Towangp 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000065: probable bug in .stseg grades
DescriptionWe can't bootcheck in asm_fast.gc.decldebug.stseg. This is on saturn. The
compiler crashes when trying to make the stage 2 dependencies:

% MERCURY_OPTIONS= mmake depend
...
make[1]: *** [mer_std.depend] Illegal instruction
make[1]: Leaving directory `/home/saturn/wangp/ws_try_debug_stseg_bootcheck/stage2/library'


The crash goes away if you bump up the nondet stack size (e.g. --nondetstack-size 8192).
TagsNo tags attached.
Attached Files? nondet_stseg.m (1,413) 2008-07-18 17:09
https://bugs.mercurylang.org/file_download.php?file_id=53&type=bug
diff nondetstseg2.diff (15,373) 2008-08-01 14:53
https://bugs.mercurylang.org/file_download.php?file_id=57&type=bug

Notes
(0000105)
wangp   
2008-07-18 17:12   
I think this has nothing to do with debugging. The nondet stack segments
code seems just not to have been tested before.

The attached program crashes in asm_fast.gc.stseg if you set
MERCURY_OPTIONS=--nondet-stack-size <n> low enough to require more nondet
stack segments.

----

Some debugging notes:

* MR_nondetstack_extend_and_check calls MR_new_nondetstack_segment with
a second argument `incr', which is MR_NONDET_FIXED_SIZE + n. But we add
MR_NONDET_FIXED_SIZE again in MR_new_nondetstack_segment so
MR_NONDET_FIXED_SIZE is added twice.

* The start of MR_pop_nondetstack_segment is:

    orig_maxfr = (MR_Word *) MR_stackvar(1);
    orig_succip = (MR_Code *) MR_stackvar(2);

which looks suspiciously close to the corresponding lines in
MR_pop_detstack_segment. I think the value of maxfr should be restored from
the nondet stack, given that's where it's saved. And what's succip doing here?
(0000110)
wangp   
2008-08-01 14:57   
nondetstseg2.diff contains my attempt to fix this.
MR_pop_nondetstack_segment() seems to pop off the top stack segment correctly
now. However, it seems MR_pop_nondetstack_segment() can be called prematurely
(I'm not sure why) leading to missing solutions.

Uploading the incomplete fix in case zs or someone else knows what to do.
(0000115)
wangp   
2008-08-07 11:20   
Fix committed 2008-08-07.

Issue History
2008-07-03 15:22wangpNew Issue
2008-07-18 17:09wangpFile Added: nondet_stseg.m
2008-07-18 17:12wangpNote Added: 0000105
2008-08-01 14:53wangpFile Added: nondetstseg2.diff
2008-08-01 14:57wangpNote Added: 0000110
2008-08-07 11:20wangpStatusnew => resolved
2008-08-07 11:20wangpResolutionopen => fixed
2008-08-07 11:20wangpAssigned To => wangp
2008-08-07 11:20wangpNote Added: 0000115