[fpc-devel] threads crash on FreeBSD 9 RC1, FPC 2.6RC1

Helmut Hartl helmut.hartl at firmos.at
Tue Nov 8 20:19:09 CET 2011


Hi,

while testing our code on freebsd 9RC1/32 bit with fpc 2.6rc1
it seems that all programs compiled on that system using threads crash
with an "Illegal Instruction 4 (core dumped)" error.
Binaries compiled on Freebsd 8.2/32 and transferred to the 9RC1 box work,
which is a bit strange.

Any ideas ?

further details below:

Simple test case:

---
program thrd;
{$mode objfpc}{$H+}
uses
   cthreads,Classes;
type
    T=class(TThread)
    private
     i:integer;
     procedure Execute;override;
    end;

procedure T.Execute;
begin
   inc(i);
end;
begin
   T.create(false);
end.

---

After compiling fpc 2_6 fixes with debug info, and running the program
gdb stops at the below marked line in cthreads.pp

     procedure CAllocateThreadVars;
       var
         dataindex : pointer;
       begin
         { we've to allocate the memory from system  }
         { because the FPC heap management uses      }
         { exceptions which use threadvars but       }
         { these aren't allocated yet ...            }
         { allocate room on the heap for the thread vars }
 >>>>>      
DataIndex:=Pointer(Fpmmap(nil,threadvarblocksize,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0));
         FillChar(DataIndex^,threadvarblocksize,0);
         pthread_setspecific(tlskey,dataindex);
       end;

-- 
helmut



More information about the fpc-devel mailing list