Re: [RFC PATCH] LoongArch: Fix intermittent nptl/tst-cancel32 failure

mengqinggang <[email protected]> Wed, 5 Aug 2026 10:09:25 +0800
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------1NWU9F46Js8QyhG004qFkT4H
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi Wilco,

I'm sorry, I don't think I fully understood your point.

On LoongArch64:
PTR_DEMANGLE2 (sp, t0, t1)

expand to:

rotri.d         $sp, $t0, 0x11
xor             $sp, $sp, $t1


The SP register is partially updated between the rotri.d and xor 
instructions.
Using this value in the pthread_cancel path may cause a SIGSEGV.

I think this issue is not relate to t0 register.


在 2026/8/4 21:50, Wilco Dijkstra 写道:
> Hi Mengqinggang,
>
>> 	REG_L t0, a0, 0*SZREG
>> -	PTR_DEMANGLE (ra, t0, t1)
>> +	PTR_DEMANGLE (ra, t0, t1, t2)
>> 	REG_L t0, a0, 1*SZREG
>> -	PTR_DEMANGLE2 (sp, t0, t1)
>> +	PTR_DEMANGLE2 (sp, t0, t1, t2)
> Isn't t0 already a temporary in PTR_DEMANGE as the code above shows?
> For mangling, dst is the temporary (and thus cannot be SP), for demangling,
> src is the temporary (and thus cannot be SP).
>
> Cheers,
> Wilco
--------------1NWU9F46Js8QyhG004qFkT4H
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi Wilco,</p>
    <p>I'm sorry, I don't think I fully understood your point.</p>
    On LoongArch64:<br>
    <span style="white-space: pre-wrap">PTR_DEMANGLE2 (sp, t0, t1)</span>
    <pre wrap="" class="moz-quote-pre">
expand to:

rotri.d         $sp, $t0, 0x11
xor             $sp, $sp, $t1
</pre>
    <br>
    The SP register is partially updated between the rotri.d and xor
    instructions.<br>
    Using this value in the pthread_cancel path may cause a SIGSEGV.
    <p>I think this issue is not relate to t0 register.</p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">在 2026/8/4 21:50, Wilco Dijkstra 写道:<br>
    </div>
    <blockquote type="cite"
cite="mid:PAWPR08MB8982C508807F5B068A44AEC383D42@PAWPR08MB8982.eurprd08.prod.outlook.com">
      <pre wrap="" class="moz-quote-pre">Hi Mengqinggang,

</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">	REG_L t0, a0, 0*SZREG
-	PTR_DEMANGLE (ra, t0, t1)
+	PTR_DEMANGLE (ra, t0, t1, t2)
	REG_L t0, a0, 1*SZREG
-	PTR_DEMANGLE2 (sp, t0, t1)
+	PTR_DEMANGLE2 (sp, t0, t1, t2)
</pre>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
Isn't t0 already a temporary in PTR_DEMANGE as the code above shows?
For mangling, dst is the temporary (and thus cannot be SP), for demangling,
src is the temporary (and thus cannot be SP).

Cheers,
Wilco</pre>
    </blockquote>
  </body>
</html>

--------------1NWU9F46Js8QyhG004qFkT4H--