[fpc-pascal]Crashes with multithreading

Nico Erfurth masta at computerman.de
Mon Dec 11 18:26:00 CET 2000


>> 
>> JM> FPC's heap manager and IO functions (writeln/readln) are *not* thread 
>> JM> safe. That's probably what's causing the crashes. Add the cmem unit (from 
>> JM> the "packages" units) as the first unit in your "uses" clause, then 
>> JM> you're at least safe on the memory management side. You can't use heaptrc 
>> JM> with it though.
>> Thank you for such fast reply. But if IO operations not thread safe,
>> does it means that all file operations also unsafe ?

> Shortly said: Yes. The only solution for this is to use separate
> streams in each thread, then it'll work fine.

The problem is, nothing in FPC is threadsafe, even the TThread-Class 
itself (InitThreads/DoneThreads).
The FPC-Team really needs to make the RTL and all other classes 
threadsafe. Its nearly impossible to trace errors in threaded applications.

regards Nico Erfurth





More information about the fpc-pascal mailing list