On 02/01/2019 21:22, Benito van der Zander wrote:
Hi,
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?
No:
// global var
var
Foo: String;
// main thread
Foo := getsomestring_with_refcount_1();
TMyThread.Create(false); // not suspended / start
Foo := ''; // de-ref
//TMyThread.Execute
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
accessed?
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel