Skip to content

GetRandBytes() Hangs on Samsung Galaxy S25 and OnePlus 13 #31817

@giahuy98

Description

@giahuy98

Is there an existing issue for this?

  • I have searched the existing issues

Current behaviour

We have been using Bitcoin Core natively in the Nunchuk Bitcoin wallet, available on both desktop and mobile. On Samsung Galaxy S25 and OnePlus 13 (both running Android 15 with the SM8750-AB Snapdragon 8 Elite 3nm processor), the app fails to initialize due to an issue in GetRandBytes().

The problem occurs when GetRandBytes() calls GetRNDRRS(), resulting in an infinite loop without retrieving entropy from the hardware.

uint64_t GetRNDRRS() noexcept
{
    uint8_t ok;
    uint64_t r1;
    do {
        // https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDRRS--Reseeded-Random-Number
        __asm__ volatile("mrs %0, s3_3_c2_c4_1; cset %w1, ne;"
                         : "=r"(r1), "=r"(ok)::"cc");
        if (ok) break;
        __asm__ volatile("yield");
    } while (true);
    return r1;
}

Build with: Android NDK 25.1.8937393 & 27.2.12479018

Related PR: #26839

Tested on commit: 57b47c47ef0bd36e1c32d709c62998c51dc76f34

Expected behaviour

GetRandBytes() should return entropy without hanging.

Steps to reproduce

  • Build Bitcoin Core for Android on master or 57b47c4
  • Call GetRandBytes
  • Function gets stuck

Relevant log output

No response

How did you obtain Bitcoin Core

Compiled from source

What version of Bitcoin Core are you using?

master@57b47c47ef0bd36e1c32d709c62998c51dc76f34

Operating system and version

Android 15

Machine specifications

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions