Преглед на файлове

Fixed assert triggered by new fuzzy test. Unit-test updated.

Marco Bambini преди 8 години
родител
ревизия
6eda92e1c4

+ 4 - 1
src/compiler/gravity_codegen.c

@@ -1368,7 +1368,10 @@ static void visit_postfix_expr (gvisitor_t *self, gnode_postfix_expr_t *node) {
 					if (dest_is_temp && last_register == dest_register) dest_is_temp = false;
 				}
 				if (dest_is_temp) ircode_register_push(code, dest_register);
-				ircode_register_protect_outside_context(code, dest_register);
+                if (!ircode_register_protect_outside_context(code, dest_register)) {
+                    report_error(self, (gnode_t *)subnode, "Invalid register access.");
+                    return;
+                }
 			}
 			
 			// free temp args array

+ 10 - 3
src/compiler/gravity_ircode.c

@@ -434,11 +434,12 @@ uint32_t ircode_register_pop_context_protect (ircode_t *code, bool protect) {
 	return value;
 }
 
-void ircode_register_protect_outside_context (ircode_t *code, uint32_t nreg) {
-	if (nreg < code->nlocals) return;
-	assert(code->state[nreg]);
+bool ircode_register_protect_outside_context (ircode_t *code, uint32_t nreg) {
+	if (nreg < code->nlocals) return true;
+    if (!code->state[nreg]) return false;
 	bool *context = marray_last(code->context);
 	context[nreg] = false;
+    return true;
 }
 
 void ircode_register_protect_in_context (ircode_t *code, uint32_t nreg) {
@@ -488,6 +489,12 @@ void ircode_register_clear (ircode_t *code, uint32_t nreg) {
 	if (nreg >= code->nlocals) code->state[nreg] = false;
 }
 
+void ircode_register_set (ircode_t *code, uint32_t nreg) {
+    if (nreg == REGISTER_ERROR) return;
+    // set busy mask only if it is a temp register
+    if (nreg >= code->nlocals) code->state[nreg] = true;
+}
+
 uint32_t ircode_register_last (ircode_t *code) {
 	if (marray_size(code->registers) == 0) return REGISTER_ERROR;
 	return (uint32_t)marray_last(code->registers);

+ 2 - 1
src/compiler/gravity_ircode.h

@@ -104,11 +104,12 @@ uint32_t	ircode_register_push_temp (ircode_t *code);
 uint32_t	ircode_register_push (ircode_t *code, uint32_t nreg);
 uint32_t	ircode_register_pop (ircode_t *code);
 uint32_t	ircode_register_pop_context_protect (ircode_t *code, bool protect);
-void		ircode_register_protect_outside_context (ircode_t *code, uint32_t nreg);
+bool		ircode_register_protect_outside_context (ircode_t *code, uint32_t nreg);
 void		ircode_register_protect_in_context (ircode_t *code, uint32_t nreg);
 uint32_t	ircode_register_last (ircode_t *code);
 uint32_t	ircode_register_count (ircode_t *code);
 void		ircode_register_clear (ircode_t *code, uint32_t nreg);
+void        ircode_register_set (ircode_t *code, uint32_t nreg);
 void		ircode_register_dump (ircode_t *code);
 
 void		ircode_register_set_skip_clear (ircode_t *code, uint32_t nreg);

+ 1 - 0
test/fuzzy/2017-05-10/id:000000,sig:06,src:001812+003201,op:splice,rep:2.gravity

@@ -0,0 +1 @@
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""9""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""X\(1 ) \(1 ())@\(1 () )X\(1 )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 ) \(1 )h\(1 )?\(1  )X\(1 )?\(1 )(1 X\(1 ) \ ) \(1)XX\(1 ) \(1)X\ )X\(1 )?\(1 )(1 X\(1 ) \(1 ())\(1 (),)X\(1 ) \(1  )X\ )h\(1  ))M\(1 ())@\(1 () )X\(1 ) v(1 ())@\(1 () )X\(1 ) \(1  )))@\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1) )X\(1 ) \(1  )))@\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 ) \(1 )h\(1 )?\(1  )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 ) \(1   ())@\(1 () )X\(1 ) \(1)X\ )X\(1 )?\(1 )(1 X\(1 ) \(1 ())\(1 (),)X\(1 ) \(1 )h\(1 \  ))M\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 ) \(1  )))@\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\ )X\(1 )?\(1 )(1 X\(1 ) \(1 ())\(1 (),)X\(1 ) \(1 )h\(1 \  ))M\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 ) \(1  )))@\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 ) \(1  )X\ )h\(1 )?\(1 )(1 )??"

+ 1 - 0
test/fuzzy/2017-05-10/id:000000,sig:06,src:003209,op:havoc,rep:8.gravity

@@ -0,0 +1 @@
+")@\(1 (1)@\)M""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""\(1 ())@\(1 () )X\(1 ) \(1 ())5\(1 () )X\(1 )  (1 ))@|(1 ())@\(1 () )X\(1 ) \(1)@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 ) \(1 ))@\(1 ())@\(1 ()ミ)X\(1 ) \(1 ())@\(1 () )X\(1 )?$(1 )(1 )??"

+ 1 - 0
test/fuzzy/2017-05-10/id:000001,sig:06,src:001812+003202,op:splice,rep:2.gravity

@@ -0,0 +1 @@
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(""""(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 ) \(1 )h\(1 )?\(1  )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 ) \(1   ())@\(1 () )X\(1 ) \(1)X\ )X\(1 )?\(1 )(1 X\(1 ) \(1 ())\(1 d),)X\(1 ) \(1 )h\(1 \  ))M\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 ) \(1  )))@\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 ) \(1  )X\ )h\(1 )?\(1 )(1 )??"

+ 2 - 0
test/fuzzy/2017-05-10/id:000001,sig:06,src:002633+003787,op:splice,rep:2.gravity

@@ -0,0 +1,2 @@
+23.3%0{7}
+((1.F)(1.F() ()(((1.F)) ()(1.g)) (1.FA) ()) ()(1(1.g)) (1._)) ()

+ 1 - 0
test/fuzzy/2017-05-10/id:000002,sig:06,src:001812+003202,op:splice,rep:2.gravity

@@ -0,0 +1 @@
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 ) \(1 )h\(1 )?\(1  )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 )))M\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 ) \(1  )))@\(1 ())@\(1 () )X\(1 ) \(1 ())@\(1 () )X\(1 )X\(1 )?\(1 )(1 X\(1 ) \(1 ())@\(1 (),)X\(1 ) \(1  )X\ )h\(1 )?\(1 )(1 )??"

+ 2 - 0
test/fuzzy/2017-05-10/id:000002,sig:06,src:003786,op:havoc,rep:4.gravity

@@ -0,0 +1,2 @@
+4!{ }0{7}
+((1.F)(1.F() ()(((1.X
) ()(1.g)) (1.FA) ()) ()(1(1.g)) *1.9)) ()

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
test/fuzzy/2017-05-10/id:000003,sig:06,src:001812+004068,op:splice,rep:2.gravity


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
test/fuzzy/2017-05-10/id:000004,sig:06,src:001821+003209,op:splice,rep:2.gravity


Някои файлове не бяха показани, защото твърде много файлове са промени