Skip to content

ffi: toArrayBuffer() aborts on allocation failure instead of throwing #66405

Description

@trivikr

Version

main

Platform

macOS 26.7.0

Subsystem

ffi

What steps will reproduce the bug?

import { toBuffer, toArrayBuffer } from 'node:ffi';

try { toBuffer(1n, 2 ** 50); } catch (e) { console.log(e.code); }
try { toArrayBuffer(1n, 2 ** 50); } catch (e) { console.log(e.code); }

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Both calls throw a catchable ERR_MEMORY_ALLOCATION_FAILED, as ffi.toBuffer() already does:

ERR_MEMORY_ALLOCATION_FAILED
ERR_MEMORY_ALLOCATION_FAILED

What do you see instead?

ffi.toBuffer() throws, but ffi.toArrayBuffer() aborts the process (exit code 134):

ERR_MEMORY_ALLOCATION_FAILED
FATAL ERROR: v8::ArrayBuffer::NewBackingStore Allocation failed - process out of memory

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ffiIssues and PRs related to experimental Foreign Function Interface support.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions