Skip to content

uclibc-compat: fix __aeabi_d2iz infinite recursion#2002

Merged
widgetii merged 1 commit intomasterfrom
fix-aeabi-d2iz-recursion
Apr 13, 2026
Merged

uclibc-compat: fix __aeabi_d2iz infinite recursion#2002
widgetii merged 1 commit intomasterfrom
fix-aeabi-d2iz-recursion

Conversation

@widgetii
Copy link
Copy Markdown
Member

Problem

__aeabi_d2iz in libuclibc-compat.so caused a stack overflow (infinite recursion). GCC converts (int)x to a call to __aeabi_d2iz — which is the function itself.

Found via AddressSanitizer on hi3516cv100 hardware (128MB RAM, osmem=96M for ASAN headroom):

==821==ERROR: AddressSanitizer: stack-overflow on address 0xbe520ff8
    #0 0x400b4894  (/usr/lib/libuclibc-compat.so+0x894)

Disassembly confirmed the recursion:

__aeabi_d2iz:
    push {r4, lr}
    bl   __aeabi_d2iz@plt    ; calls itself!
    pop  {r4, pc}

Fix

Replace with manual IEEE 754 double field extraction using only integer operations.

Test plan

  • ASAN build of majestic passes hisi_free_mem_ex (was crashing here)
  • Sensor initializes: "Sony IMX122 Sensor Initial OK!"
  • SDK starts: "HiSilicon SDK started"
  • Full hardware test after toolchain rebuild + firmware build

Ref: #1992

GCC converts `(int)x` (double-to-int cast) into a call to __aeabi_d2iz,
which is the function itself — causing infinite recursion and a stack
overflow.  Found via AddressSanitizer on hi3516cv100 hardware.

Replace with manual IEEE 754 double field extraction that uses only
integer operations, breaking the recursion.

Ref: #1992

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit 4c22132 into master Apr 13, 2026
88 checks passed
@widgetii widgetii deleted the fix-aeabi-d2iz-recursion branch April 14, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant