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

Pierre Free Pascal pierre at freepascal.org
Wed Nov 9 14:12:18 CET 2011


> 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.

  There is no warranty that an executable for a given version
will work on a later...
  If only one system call interface is changed, this is enough to break
everything!
 
> 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;

  What does 
(gdb) x /10i $rip 
(or $eip if it is an i386 executable)
give as output?

Pierre Muller




More information about the fpc-devel mailing list