[fpc-devel] ref count types / threadsave question
lazarus at mfriebe.de
Wed Jan 2 21:46:41 CET 2019
On 02/01/2019 21:22, Benito van der Zander wrote:
> but if another core can do anything to the string, the refcount should
> already be 2, one for this core and one for the other core, should it not?
// global var
// main thread
Foo := getsomestring_with_refcount_1();
TMyThread.Create(false); // not suspended / start
Foo := ''; // de-ref
LocalFoo := Foo; // copy from the global var
If the main threads "Foo:=''; " is executed ...
- beginning right after fpc_AnsiStr_Incr_Ref in TMyThread did the NIL test
- and finished before the "inclocked"
then the inclocked operates in memory freed in the main thread?
Unless there is some thread save checking each time a global var is
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel