[M3devel] pthreads on FreeBSD, was: endless exception loop on FreeBSD

Olaf Wagner wagner at elegosoft.com
Sun Dec 23 16:36:40 CET 2007


>> On Dec 21, 2007, at 7:22 AM, Olaf Wagner wrote:
>>
>>> I'm trying to add pthread support to the FreeBSD4 platform.
>>> My first tentative additions now lead to endless exception loops
>>> once any error is encountered until the stack overflows.
>>>
>>> Does anybody know what's wrong here? I'm not aware that I have
>>> changed anything in this area.
>>
> I seems that I have been linking against a non-reentrant libc. I can
> now get a little
> farther:
>
> % ./m3-sys/cm3/FreeBSD4/cm3 -help @M3debugthreads
> Stopping from act=0x8a93500
> Stopping act=0x8a93b80
> Stopped act=0x8a93b80
> Stopped from act=0x8a93500
> Processing act=0x8a93500
> Processing act=0x8a93b80
> Starting from act=0x8a93500
> Starting act=0x8a93b80
> Started act=0x8a93b80
> Started from act=0x8a93500
> Stopping from act=0x8a93500
> Stopping act=0x8a93b80
> Stopped act=0x8a93b80
> Stopped from act=0x8a93500
> Processing act=0x8a93500
> Processing act=0x8a93b80
> Starting from act=0x8a93500
> Starting act=0x8a93b80
> Started act=0x8a93b80
> Started from act=0x8a93500
> CStatus failed with errno 2
>
>
> ***
> *** runtime error:
> ***    Unhandled exception: OSError.E
> ***    file "../src/os/POSIX/OSErrorPosix.m3", line 50
> ***
>
> Abort trap (core dumped)
>
> This is the compiler trying to locate cm3.cfg at different locations.
> It doesn't find it and an OSError.E is raised, which should get caught
> in M3File.IsReadable, but isn't. So it seems exception handling is
> broken as soon as I use system threads. Any ideas on this one?

Some additional information:

It is really only the PTHREAD setting in m3core/src/thread/m3makefile
which makes exceptions fail. If I change it and compile everything again,
I get this output from cm3:

% ./m3-sys/cm3/FreeBSD4/cm3 -help @M3debugthreads
DetermineContext: oldSP = 0xbfbfe74c
modelSP:    0xbfbfe70c
oldSP:      0xbfbfe74c
frame size: 64
CStatus failed with errno 2
CStatus failed with errno 2
CStatus failed with errno 2
CStatus failed with errno 2
CStatus failed with errno 2
CStatus failed with errno 2
Critical Mass Modula-3 version d5.5.0
   last updated: 2007-12-17
   configuration: /usr/local/cm3/bin/cm3.cfg
[...]

So all OSError.E exceptions for stat failures are caught, and there
are no thread switches at the start of the compiler; it only sets
up the model frame for userlevel threads.
In contrast, system level pthreads show much activity at the start
(why?), and the first exception terminates the compiler.

I still haven't got a good explanation for this. Unfortunately,
the FreeBSD gdb debugger does not really seem to cope well with threaded
programs... All interesting information always is unrecoverable.

Olaf
-- 
Olaf Wagner -- elego Software Solutions GmbH
                Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
phone: +49 30 23 45 86 96  mobile: +49 177 2345 869  fax: +49 30 23 45 86 95
    http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194




More information about the M3devel mailing list