Kaynağa Gözat

Merged revisions 11596,11619,11621-11622,11628,11664-11667,11670,11672,11683,11685,11689-11692,11694-11696,11698,11701-11702,11705-11707,11712-11718,11723-11726,11728-11729,11733-11737,11773 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r11596 | jonas | 2008-08-16 22:51:52 +0200 (Sat, 16 Aug 2008) | 3 lines

* Don't inline ioresult. It's not speed critical and inlining it causes
code bloat.
........
r11672 | jonas | 2008-08-31 12:07:53 +0200 (Sun, 31 Aug 2008) | 3 lines

* only set dynarray pointer to nil in decref in case the last reference
has been destroyed (mantis #12000)
........
r11773 | jonas | 2008-09-13 22:01:47 +0200 (Sat, 13 Sep 2008) | 2 lines

* set finalized dynarrays to nil (mantis #12048)
........

git-svn-id: branches/fixes_2_2@12149 -

joost 17 yıl önce
ebeveyn
işleme
9cf3a14ae8

+ 2 - 0
.gitattributes

@@ -8116,8 +8116,10 @@ tests/webtbs/tw11852.pp svneol=native#text/plain
 tests/webtbs/tw11861.pp svneol=native#text/plain
 tests/webtbs/tw11862.pp svneol=native#text/plain
 tests/webtbs/tw11896.pp svneol=native#text/plain
+tests/webtbs/tw12000.pp svneol=native#text/plain
 tests/webtbs/tw1203.pp svneol=native#text/plain
 tests/webtbs/tw1204.pp svneol=native#text/plain
+tests/webtbs/tw12048.pp svneol=native#text/plain
 tests/webtbs/tw12051.pp svneol=native#text/plain
 tests/webtbs/tw1207.pp svneol=native#text/plain
 tests/webtbs/tw12186.pp svneol=native#text/plain

+ 4 - 2
rtl/inc/dynarr.inc

@@ -106,8 +106,10 @@ procedure fpc_dynarray_decr_ref(var p : pointer;ti : pointer); [Public,Alias:'FP
      { decr. ref. count }
      { should we remove the array? }
      if declocked(realp^.refcount) then
-       fpc_dynarray_clear_internal(realp,pdynarraytypeinfo(ti));
-     p := nil;
+       begin
+         fpc_dynarray_clear_internal(realp,pdynarraytypeinfo(ti));
+         p := nil;
+       end;
   end;
 
 { provide local access to dynarr_decr_ref for dynarr_setlength }

+ 4 - 1
rtl/inc/rtti.inc

@@ -167,7 +167,10 @@ begin
         PPointer(Data)^:=nil;
       end;
     tkDynArray:
-      fpc_dynarray_decr_ref(PPointer(Data)^,TypeInfo);
+      begin
+        fpc_dynarray_decr_ref(PPointer(Data)^,TypeInfo);
+        PPointer(Data)^:=nil;
+      end;
     tkVariant:
       variant_clear(PVarData(Data)^);
   end;

+ 1 - 1
rtl/inc/system.inc

@@ -624,7 +624,7 @@ begin
 end;
 
 
-Function IOResult:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function IOResult:Word;
 var
   HInoutRes : PWord;
 Begin

+ 1 - 1
rtl/inc/systemh.inc

@@ -720,7 +720,7 @@ function get_frame:pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
 function get_caller_addr(framebp:pointer):pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
 function get_caller_frame(framebp:pointer):pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
 
-Function IOResult:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+Function IOResult:Word;
 Function Sptr:Pointer;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_ptr];
 
 {$ifdef FPC_HAS_FEATURE_PROCESSES}

+ 33 - 0
tests/webtbs/tw12000.pp

@@ -0,0 +1,33 @@
+program arcrash;
+
+{$mode objfpc}{$H+}
+
+type
+  Trec = record
+    Signature: array of Integer;
+    s: ansistring;
+  end;
+
+var
+  M: array of Trec;
+  s2: ansistring;
+
+begin
+  SetLength(M,2);
+  SetLength(M[0].Signature,4);
+  SetLength(M[1].Signature,4);
+  setlength(m[0].s,2);
+  s2:=m[0].s;
+  WriteLn(Length(M[0].Signature), ' ', Length(M[1].Signature));
+  writeln(length(m[0].s));
+  M[0].Signature := M[0].Signature;
+  m[0].s:=m[0].s;
+  WriteLn(Length(M[0].Signature), ' ', Length(M[1].Signature));
+  writeln(length(m[0].s));
+  s2:='';
+  if (Length(M[0].Signature) <> 4) then
+    halt(1);
+  if (Length(M[0].s) <> 2) then
+    halt(2);
+end.
+

+ 24 - 0
tests/webtbs/tw12048.pp

@@ -0,0 +1,24 @@
+{ %opt=-gh }
+
+{$mode objfpc}
+
+program DynArrBug;
+
+uses Types;
+
+function GetDynArray: TStringDynArray;
+begin
+  SetLength( GetDynArray, 16 );
+end;
+  
+var
+  darr: array[1..1] of TStringDynArray;
+begin
+  keepreleased:=true;
+  darr[1] := GetDynArray();
+  Finalize( darr[1] );
+  if pointer(darr[1])<>nil then
+    halt(1);
+  darr[1] := GetDynArray();
+end.
+