Skip to content

Fix FFI calling conventions inside nested declarators - #25126

Open
nicolas-grekas wants to merge 1 commit into
php:PHP-8.4from
nicolas-grekas:ffi-nested-callconv
Open

nicolas-grekas wants to merge 1 commit into
php:PHP-8.4from
nicolas-grekas:ffi-nested-callconv

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Contributor

FFI ignores the calling convention in void (__stdcall *f)(void). That's how Windows headers declare callbacks, for example PAPCFUNC. On x86, such a callback is created as cdecl. The callback then doesn't pop its argument and the stdcall caller crashes. That's why sleep_alertable_win32.phpt from #24399 crashes on nightly (#25125 changes the test).

In a parameter or a type name, as in FFI::type('void (__stdcall *)(int)'), the same syntax fails with "Unsupported type specifier combination".

A convention that the platform doesn't support is now rejected inside the parentheses too, like it already is before them. For example, void (__stdcall *f)(void) now throws on x64.

I updated ffi_parser.c by hand, the same way LLK generates the other cases.

FFI ignored the calling convention in "void (__stdcall *f)(void)", and
failed to parse it in parameters and type names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant