[PATCH] microblaze: fix __syscall_cancel_arch
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Fri Oct 17 12:39:45 GMT 2025
On 17/10/25 09:36, Luc Michel wrote:
> On 09:22 Fri 17 Oct , Adhemerval Zanella Netto wrote:
>> On 17/10/25 06:27, Luc Michel wrote:
>>> The __syscall_cancel_arch function has an epilogue that does not match
>>> the prologue. The stack is not used and the return address still lies in
>>> r15 when reaching the epilogue. Fix the epilogue by simply returning
>>> from the function.
>>>
>>> Signed-off-by: Luc Michel <luc.michel@amd.com>
>>
>> LGTM. How did you tested? I tried to come up with an simulated microblaze
>> environment, but there is no official qemu support (only qemu-user).
>
> I tested using the following reproducer provided by Gopi (CC'ed) and
> modified a bit to track down the issue:
>
> 8<-------------------------------------------------------------
>
> #include <thread>
> #include <vector>
> #include <iostream>
>
> void worker(std::size_t n)
> {
> unsigned volatile int count = 1 << 31;
>
> std::cout << "hello thread\n";
>
> while (count--);
>
> std::cout << "bye thread\n";
> }
>
> int main()
> {
> std::thread t(worker, 1);
>
> t.join();
> return 0;
> }
>
> 8<-------------------------------------------------------------
>
> The failure was actually reported to me using qemu-user.
>
> I reproduced it like this, building a toolchain using buildroot:
>
> ~/work/buildroot/output/host/bin/microblazeel-buildroot-linux-gnu-g++ -static -g3 -o qemu-crash qemu-crash.cc
> ~/work/build/qemu-debug/qemu-microblazeel -L ~/work/buildroot/output/host/microblazeel-buildroot-linux-gnu/sysroot ./qemu-crash
>
> Without this patch, QEMU execution ends up with a segmentation fault.
> With the patch applied it works fine.
>
Thanks for the explanation, I have opened BZ#33547 [1] to track it.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=33547
More information about the Libc-alpha
mailing list