Page MenuHomeFreeBSD

libc: Fix longjmp/_longjmp(buf, 0) for AArch64, MIPS and RISC-V
ClosedPublic

Authored by jrtc27 on Mar 21 2021, 4:01 PM.
Tags
None
Referenced Files
F102786180: D29363.diff
Sun, Nov 17, 4:29 AM
Unknown Object (File)
Tue, Nov 12, 6:45 PM
Unknown Object (File)
Oct 8 2024, 7:52 PM
Unknown Object (File)
Sep 17 2024, 7:54 AM
Unknown Object (File)
Sep 16 2024, 4:25 PM
Unknown Object (File)
Sep 8 2024, 2:21 PM
Unknown Object (File)
Sep 8 2024, 12:16 PM
Unknown Object (File)
Sep 5 2024, 10:42 AM
Subscribers

Details

Summary

All three of these architectures fail to handle this special case, and
will cause the corresponding setjmp/_setjmp to return 0 rather than 1.
Fix this and add regression tests (also committed upstream).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37973
Build 34862: arc lint + arc unit

Event Timeline

lib/libc/mips/gen/setjmp.S
224

This file is full of sadness wrt delay slots; they're not exposed here (despite being exposed in _setjmp.S!), but you would be forgiven for thinking otherwise when looking at most (but not all) of the existing branches...

This looks good to me but probably best to wait until someone else has had a look.

This revision is now accepted and ready to land.Mar 22 2021, 11:19 AM

Are the in-kernel impls also broken?

In D29363#657983, @jhb wrote:

Are the in-kernel impls also broken?

Interesting question with an interesting answer:

  • amd64 - Hard-coded return value of 1
  • arm - Hard-coded return value of 1
  • arm64 - Returns argument without handling 0 properly
  • i386 - Hard-coded return value of 1
  • mips - Hard-coded return value of 1
  • powerpc - Hard-coded return value of 1
  • riscv - Returns argument without handling 0 properly

So every architecture is wrong. Gah.