<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 02/01/2019 21:22, Benito van der
Zander wrote:<br>
</div>
<blockquote type="cite"
cite="mid:f99656ae-975c-7ba4-c213-f30bae31de47@benibela.de">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div id="smartTemplate4-template">Hi,<br>
</div>
<div><br>
</div>
<div>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?<br>
</div>
</blockquote>
No:<br>
<br>
// global var<br>
var<br>
Foo: String;<br>
<br>
// main thread<br>
Foo := getsomestring_with_refcount_1();<br>
TMyThread.Create(false); // not suspended / start<br>
<br>
Foo := ''; // de-ref <br>
<br>
//TMyThread.Execute<br>
LocalFoo := Foo; // copy from the global var<br>
<br>
If the main threads "Foo:=''; " is executed ...<br>
- beginning right after fpc_AnsiStr_Incr_Ref in TMyThread did the
NIL test<br>
- and finished before the "inclocked"<br>
then the inclocked operates in memory freed in the main thread?<br>
<br>
Unless there is some thread save checking each time a global var is
accessed?<br>
<br>
</body>
</html>