[fpc-pascal] writeln: FPC runtime race conditions in external C threads
alex at grauonline.de
Mon Jul 12 13:34:25 CEST 2010
Am 12.07.2010 um 13:24 schrieb Michael Van Canneyt:
> Basically, any heap memory access and standard pascal I/O are
> forbidden in
> threads started outside FPC, because the necessary thread structures
> are not
> initialized correctly.
Is my assumption correct that this means I cannot use much of FPC
then? As far as I can see, calling an object seems to be possible
without any crash (aren't these on the heap too ?).
Due to these limitations, I think the best then would be to switch
from the C callback thread into the FPC thread - how would that be
> On Mon, 12 Jul 2010, Alexander Grau wrote:
>> While using an external C framework (Mac OS X, discrecording OS
>> framework, FPC 2.4), I noticed that my FPC console app crashes when
>> I use writeln's in both C threads (callbacks).
>> Example: Two FPC functions that are called from an external C
>> library (c_callback1 and c_callback2) - callback2 is called within
>> callback1 in another C thread (other than the FPC main thread).
>> // called from external C framework within the FPC main thread
>> c_callback1; cdecl;
>> // c_ callback2 is called here from another C thread
>> writeln('callback1end'); <== my FPC console app crashes here
>> ( "EInOutError - Disk Full")
>> // called from external C framework in another C thread
>> c_callback2; cdecl;
>> An unhandled exception occurred at $000669E3 :
>> EInOutError : Disk Full
>> $000669E3 CALLBACK1, line xxx
>> Question: Why isn't it safe to call writeln's in non-FPC
>> threads? Are there any other FPC runtime functions I should not
>> call within non-FPC threads?
>> I'm going to make an FPC wiki page ('Threading Pitfalls') that
>> will discuss these and other issues related to threading and I
>> welcome all explanations on this so I can better understand this
>> problem! :-)
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
Best regards / Mit freundlichen Grüßen/順致最崇高的敬意
Hardware & Software Solutions
Tel: +49 (0) 5741 2301259
Fax: +49 (0) 5741 235530
E-Mail: info at grauonline.de
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal