Skip to content

CFFI val_ocallN does not match its public argument-vector signature #228

Closed

Description

@dimensionscape

The public CFFI declaration for val_ocallN takes four arguments: object, field id, value pointer array, and argument count. The runtime implementation has only three parameters and treats the pointer-array argument as one Haxe object value.

Regression coverage first: test/regression/CffiObjectCallVector in the existing Main.hx/build.hxml/stdout.txt layout. Resolve val_ocallN through the actual hx_cffi export table and call it using the signature from CFFIAPI.h. Use a native sentinel callback that reports the number of arguments it receives without reading the malformed value. Exercise zero, one and three arguments.

Confirmed on Linux x86_64 with Haxe 4.3.3:

requested 0 arguments, received 1
requested 1 arguments, received 1
requested 3 arguments, received 1

The one-argument case matching by count does not establish correctness: it receives the value-array address rather than the array's element. The sentinel deliberately does not dereference that value.

include/hx/CFFIAPI.h declares:

DEFFUNC_4(value,val_ocallN,value,int,value *,int)

src/hx/CFFI.cpp implements:

hx::Object *val_ocallN(hx::Object *arg1, int arg2, hx::Object *arg3)

It then dispatches the field with __run(Dynamic(arg3)) on API levels below 500, or a single-argument invoker call on API level 500. It never reads the argument count or packs the value vector. hx_cffi returns that implementation under the public val_ocallN name.

Make the implementation match the exported declaration and dispatch the requested argument vector, as val_callN does. Test argument contents, zero arguments, larger arities, thrown callbacks and null receivers. Include both static-link and dynamically resolved calls so declaration/export drift is caught. The current functional reproduction is API level 430; the API level 500 branch has the same source-level mismatch but was not executed in this probe.

This affects native extensions calling object fields through CFFI. No runtime implementation changes are included.

Activity

  1. added a commit that references this issue on Oct 20, 2026
    1cc6930
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions