<div dir="ltr"><div>Thanks José, I can see that might cause a problem given bar passes result by reference to foo without initializing result first. My question to Jonas or others more knowledgeable than me about what the compiler does, is whether result (in your example and my own case) is guaranteed to be initialized to nil when it first appears in scope (i.e. before it's been assigned any value in our code). If it is initialized to nil, then foo would receive a reference to bar's result variable (via para) and the value of that variable would be nil (and all would be okay). If it isn't initialized to nil, the same rule applies but the value of result (as seen by foo via para) would likely be invalid and would probably blow up in foo when dereferenced (as a string).<br>
<br></div>My problem is similar except that I know it's not nil when passed in (because the initial test in fpc_AnsiStr_Decr_Ref looking for nil passes) but that it becomes nil very soon afterward (because the SEGV arises as an indirect result of it being nil, as I explained in my reply to Ludo just now).<br>
<br>I'm pretty sure I have a shared memory problem somewhere between threads in my code but I can't understand how this could be given the "erroneously shared" variable appears to be an automatic variable (i.e. Result) that has just been created on the stack in the function foo that calls fpc_AnsiStr_Decr_Ref where the SEGV occurs.<br>
<br>I'll keep looking :-) Bruce.<br><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 9, 2013 at 9:48 PM, José Mejuto <span dir="ltr"><<a href="mailto:joshyfun@gmail.com" target="_blank">joshyfun@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">El 09/05/2013 5:19, Bruce Tulloch escribió:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
If there is no other explanation, then it means I need to find out how<br>
the string variable referred to by (%eax) could have been been accessed<br></div>
(or even known to exist) by any other thread in the same address space.-- <br>
</blockquote>
<br>
Hello,<br>
<br>
In the past I had suffered a problem like yours and the culprit was another different function that passes result (string) as a parameter when calling a function without initialization, something like this:<br>
<br>
function foo(var para: string): string;<br>
begin<br>
  //Something with para<br>
end;<br>
<br>
function bar(): string;<br>
begin<br>
  result:=foo(result);<br>
end;<br>
<br>
I hope this helps...<div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.<u></u>org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/<u></u>mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br></div></div></div>