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
(safely) possible?
Michael.
On Mon, 12 Jul 2010, Alexander Grau wrote:
Hello,
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;
begin
writeln('callback1begin');
// c_ callback2 is called here from another C thread
writeln('callback1end'); <== my FPC console app crashes here
( "EInOutError - Disk Full")
end;
// called from external C framework in another C thread
c_callback2; cdecl;
begin
writeln('callback2begin');
writeln('callback2end');
end;
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! :-)
Thanks,
Alexander
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Best regards / Mit freundlichen Grüßen/順致最崇高的敬意
Alexander Grau
Grau GbR
Hardware & Software Solutions
Eschenweg 12
32609 Huellhorst
Germany
www.grauonline.de
Tel: +49 (0) 5741 2301259
Fax: +49 (0) 5741 235530
E-Mail: i...@grauonline.de
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal