[m-rev.] diff: add a sanity check on stack size.

Tyson Dowd trd at miscrit.be
Wed Aug 22 20:05:05 AEST 2001


Hi,


===================================================================


Estimated hours taken: 0.2
Branches: main

compiler/ilds.m:
	Add a sanity check -- make sure the stack size is never
	negative.


Index: compiler/ilds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ilds.m,v
retrieving revision 1.10
diff -u -r1.10 ilds.m
--- compiler/ilds.m	13 Aug 2001 01:39:31 -0000	1.10
+++ compiler/ilds.m	22 Aug 2001 10:09:03 -0000
@@ -439,6 +439,13 @@
 	;
 		NewCurrent = Current + get_stack_difference(I),
 		NewMax = max(NewCurrent, Max)
+	),
+		% This is a sanity check, the stack should never have a
+		% negative size.
+	( NewCurrent < 0 ->
+		error("stack underflow while calculating max stack")
+	;
+		true
 	).
 
 	% Return the difference in stack height after an instruction is

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list