Mercury Bugs - mercury
View Issue Details
0000314mercuryBugpublic2014-01-30 18:252014-04-22 16:56
Reporterzs 
Assigned Tozs 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000314: macros creating temporary frames for det & nondet stack ignore the need for new stack segments
DescriptionThe code inside #ifdef MR_STACK_SEGMENTS in runtime/mercury_stacks.h only considers the main stack frames on the det and nondet stacks, the ones we allocate at procedure entry. The temporary frames we allocate later in procedure bodies use macros that check for overflow, but do NOT allocate new segments if the allocation does not in fact fit in the current stack segment.

A minor problem is that the implications of stack segments for the handling of failures is not documented in compiler/notes/failure.html.
Steps To ReproduceFor me, the attached program, when compiled in grade asm_fast.gc.debug.stseg, will work when invoked as "bug302 1012" but not "bug302 1013". The numbers may be different in other machines, but should exist on all.
TagsNo tags attached.
Attached Files? bug302.m (1,402) 2014-01-30 18:25
https://bugs.mercurylang.org/file_download.php?file_id=196&type=bug

Notes
(0000634)
pbone   
2014-01-31 10:16   
Is it valid to create a new segment for a temporary frame? If i understand temporary frames correctly they belong to real frames. Can the temporary frame belong on a different segment from it's real frame?

Thanks.
(0000635)
zs   
2014-01-31 14:18   
Temp frames do have a redofr slot to go with the redoip slot; curfr is set from the redofr slot when backtracking to the redoip address. This SHOULD make it possible to have a temp frame on a different segment than the main frame of the relevant procedure, but the details are NOT obvious.

Also, any fix should also work for det temp frames. We will need a new test case for that, and since det temp frames are rare, creating that test case won't be easy either.
(0000661)
zs   
2014-04-22 16:56   
Fix committed april 18.

Issue History
2014-01-30 18:25zsNew Issue
2014-01-30 18:25zsFile Added: bug302.m
2014-01-31 10:16pboneNote Added: 0000634
2014-01-31 14:18zsNote Added: 0000635
2014-02-17 13:25zsAssigned To => zs
2014-02-17 13:25zsStatusnew => assigned
2014-04-22 16:56zsNote Added: 0000661
2014-04-22 16:56zsStatusassigned => closed
2014-04-22 16:56zsResolutionopen => fixed