Thanks for open a post on libsdl mailing list, but i believe it has nothing to do with sdl.

I have installed the official gph sdk and compiled the thread sample. After executing on gp2x i got following debugger output:

Code:
Starting program: /mnt/sd/Test/fpc/fpc4gp2x/fpcthread.gpe

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) info stack
#0  0x00000000 in ?? ()
#1  0x00075ecc in ptmalloc_init () at malloc.c:1760
#2  0x00077630 in malloc_hook_ini (sz=792, caller=0x75b6c) at malloc.c:1856
#3  0x000774ac in __libc_malloc (bytes=989568) at malloc.c:2797
#4  0x0004da7c in SDL_CreateThread &#40;fn=0x8118 <THREAD_FUNC>, data=0x0&#41; at SDL_thread.c&#58;228
#5  0x000081e4 in main &#40;&#41; at fpcthread.dpr&#58;26
As you can see, the gph sdk has more debug symbols insight, so we got a better error location.

I wrote a smaller sample, like this:
Code:
program fpcmalloc;
&#123;$IFNDEF FPC&#125;
  &#123;$APPTYPE CONSOLE&#125;
&#123;$ENDIF&#125;

function  malloc&#40;aSize &#58; Integer&#41;&#58; Pointer; cdecl; external;
procedure free&#40;aPtr &#58; Pointer&#41;; cdecl; external;

var
  MemPtr           &#58; Pointer;
begin
  WriteLn&#40;'Alloc 792 Bytes'&#41;;
  MemPtr &#58;= Malloc&#40;792&#41;;

  WriteLn&#40;'Release 792 Bytes'&#41;;
  Free&#40;MemPtr&#41;;
  
  WriteLn&#40;'ByeBye'&#41;;
end.
The output under gp2x is:

Code:
Starting program&#58; /mnt/sd/Test/fpc/fpc4gp2x/fpcmalloc.gpe
Alloc 792 Bytes

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? &#40;&#41;
&#40;gdb&#41; info stack
#0  0x00000000 in ?? &#40;&#41;
#1  0x00034f70 in ptmalloc_init &#40;&#41; at malloc.c&#58;1756
#2  0x0003670c in malloc_hook_ini &#40;sz=792, caller=0x0&#41; at malloc.c&#58;1856
#3  0x00036588 in __libc_malloc &#40;bytes=230028&#41; at malloc.c&#58;2797
#4  0x00008168 in main &#40;&#41; at fpcmalloc.dpr&#58;13
I don't know if I'm right, but i look at ptmalloc_init ();

Cheers,
Thomas