NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
port-mips/59285: _longjmp(..., 0) makes setjmp return 0, not 1
>Number: 59285
>Category: port-mips
>Synopsis: _longjmp(..., 0) makes setjmp return 0, not 1
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-mips-maintainer
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Apr 12 18:35:01 +0000 2025
>Originator: Taylor R Campbell
>Release: current, 10, 9, ...
>Organization:
The MipsBSD _Longjmpzero
>Environment:
>Description:
Test case: lib/libc/setjmp/t_setjmp/_longjmp_zero
Duration: 1.332031 seconds
Termination reason
FAILED: setjmp returned zero after longjmp
https://releng.netbsd.org/b5reports/pmax/2025/2025.04.11.04.54.02/test.html#lib_libc_setjmp_t_setjmp__longjmp_zero
Only happens with _longjmp, not the other versions.
Cursory examination of _setjmp.S shows that nothing is done to map 0 to 1 before passing it as the return value -- though curiously the argument a1 is both _stored_ in the jmp_buf _and moved_ to the return value register v0, when I would expect only the latter is necessary:
119 LEAF(_longjmp)
...
130 REG_S a1, _SC_REGS_V0(a0) # save return value
...
178 j ra
179 move v0, a1 # get return value in 1st arg
https://nxr.netbsd.org/xref/src/lib/libc/arch/mips/gen/_setjmp.S?r=1.26#119
There are some other instructions in the middle that use v0 as a temporary (for restoring the floating-point control and status register), but that doesn't seem to touch a1.
>How-To-Repeat:
cd /usr/tests/lib/libc/setjmp
atf-run t_setjmp | atf-report
>Fix:
Yes, please!
Home |
Main Index |
Thread Index |
Old Index