[fpc-pascal] Nil referancing doesn't raise exceptions in thread context under Linux...

Michael Van Canneyt michael.vancanneyt at wisa.be
Mon May 21 09:20:37 CEST 2007



On Sun, 20 May 2007, M. Utku Karataş wrote:

> Hi everyone,
> 
> I am using version 2.1.1 on Linux and calling this procedure in a thread:
> 
> procedure TestNullRef;
> var p: ^integer;
> begin
>    p := nil;
>    try
>        p^ := 13; // now this should raise exc!
>        ShowMessage(IntToStr(p^));
>    except
>        ShowMessage('TestNullRef: ' +
> Exception(ExceptObject).Message); // should reach!
>    end;
> end;
> 
> The problem is that caller thread just hangs up and the exception
> handler doesn't get called. When I call this procedure in my main
> thread everything is just fine.
> 
> Is there anything that renders exc. handling useless under threads?
> Any explanations?

When Linux delivers a signal (probably SIGSEGV) it doesn't deliver it to
a specific thread; It's delivered to the application as a whole. This
probably means that the main thread gets the exception signal, but doesn't
know what to do with it, since the main thread does not have an exception
stack set up.

This will require some investigation.

Michael.


More information about the fpc-pascal mailing list