浏览代码

+ give an error if allocated temps. overflow the normally max. available space

git-svn-id: trunk@30449 -
florian 10 年之前
父节点
当前提交
b684719f1e
共有 3 个文件被更改,包括 16 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 4 0
      compiler/tgobj.pas
  3. 11 0
      tests/tbf/tb0251.pp

+ 1 - 0
.gitattributes

@@ -9839,6 +9839,7 @@ tests/tbf/tb0247.pp svneol=native#text/pascal
 tests/tbf/tb0248.pp svneol=native#text/pascal
 tests/tbf/tb0248.pp svneol=native#text/pascal
 tests/tbf/tb0249.pp svneol=native#text/pascal
 tests/tbf/tb0249.pp svneol=native#text/pascal
 tests/tbf/tb0250.pp svneol=native#text/pascal
 tests/tbf/tb0250.pp svneol=native#text/pascal
+tests/tbf/tb0251.pp svneol=native#text/pascal
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain

+ 4 - 0
compiler/tgobj.pas

@@ -413,12 +413,16 @@ implementation
             { Extend the temp }
             { Extend the temp }
             if direction=-1 then
             if direction=-1 then
               begin
               begin
+                if qword(align(-lasttemp-alignmismatch,alignment))+size+alignmismatch>high(tl^.pos) then
+                  CGMessage(cg_e_localsize_too_big);
                 lasttemp:=(-align(-lasttemp-alignmismatch,alignment))-size-alignmismatch;
                 lasttemp:=(-align(-lasttemp-alignmismatch,alignment))-size-alignmismatch;
                 tl^.pos:=lasttemp;
                 tl^.pos:=lasttemp;
               end
               end
             else
             else
               begin
               begin
                 tl^.pos:=align(lasttemp+alignmismatch,alignment)-alignmismatch;
                 tl^.pos:=align(lasttemp+alignmismatch,alignment)-alignmismatch;
+                if qword(tl^.pos)+size>high(tl^.pos) then
+                  CGMessage(cg_e_localsize_too_big);
                 lasttemp:=tl^.pos+size;
                 lasttemp:=tl^.pos+size;
               end;
               end;
 
 

+ 11 - 0
tests/tbf/tb0251.pp

@@ -0,0 +1,11 @@
+{ %fail }
+procedure p;
+  var
+    { generate big local data structures which overflow the stack for sure }
+    a1,a2,a3,a4,a5 : array[0..high(sizeint) div 4] of byte;
+  begin
+  end;
+
+begin
+end.
+