Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-05

Nil referancing doesn't raise exceptions in thread context under Linux...

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

M. Utku Karataş

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?

Regards,
Utku.

Michael Van Canneyt
to M. Utku Karataş
M. Utku Karataş wrote 23 lines
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.