镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

ffi: 'void' as parameter type triggers internal assertion #63461

Description

@Renegade334

Version

26.1.0

Platform


Subsystem

ffi

What steps will reproduce the bug?

const lib = new ffi.DynamicLibrary(null);
lib.getFunction('f', { parameters: ['void'] });

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

Whenever 'void' is provided in a parameters list.

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

Unclear; the native ToFFIArgument appears to accept void arguments and just pass them as a pointer to 0, although I'm not sure how useful this behaviour is.

Either way, 'void' should either be accepted in a parameters list, or throw a validation error gracefully.

What do you see instead?

Uncaught:
Error [ERR_INTERNAL_ASSERTION]: FFI: shared-buffer type table missing entry for parameter type "void"
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at wrapWithSharedBuffer (node:internal/ffi-shared-buffer:252:13)
    at DynamicLibrary.getFunction (node:internal/ffi-shared-buffer:570:10) {
  code: 'ERR_INTERNAL_ASSERTION'

Additional information

cc: @nodejs/ffi

Activity

  1. added
    ffiIssues and PRs related to experimental Foreign Function Interface support.
    on May 20, 2026
  2. Anshikakalpana commented on May 22, 2026

    @Anshikakalpana
    Contributor

    Hi @Renegade334, I'd like to work on a fix for this.

    The native layer accepts void and passes it as a 0x0 pointer — which seems risky since a foreign function dereferencing that null pointer would segfault the whole process. That pushes me toward early validation with ERR_INVALID_ARG_VALUE.
    But I'm not sure if there's a valid use case for void parameters I'm missing. What's the intended direction — validation error, or officially support it with defined behavior?

  3. ShogunPanda commented on May 23, 2026

    @ShogunPanda
    Contributor

    I agree: there is no reason to have void in parameters.
    Given the way the code is structured, we can do this in the native layers, as both shared buffer and standard path call GetFunction and GetFunctions.

  4. Anshikakalpana commented on May 23, 2026

    @Anshikakalpana
    Contributor

    I've opened a PR for this: #63504. Thanks for the confirmation and analysis @KaloudasDev and @ShogunPanda

  5. Anshikakalpana commented on May 27, 2026

    @Anshikakalpana
    Contributor

    Thanks! Yeah, rejecting void early with a proper validation error felt much better than hitting an internal assertion.

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