openresty / openresty/luajit2

FFI will fail when calling C function with varadic parameters on apple silicon machine

Open
#117 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.4k
Forks
252
Avg merge
7d 11h
Merged PRs (30d)
3

Description

On my macpro book with m1 processor (arm64), the FFI call to printf will output random garbage characters for all varadic args.

local ffi=require'ffi'
ffi.cdef[[
   int printf(const char *fmt,...);
]]
ffi.C.printf("hello %s\n","world")

Apple has mentioned the ABI difference here. I think that's the reason. Is it complicate to support this new ABI in LuaJIT?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reproducing the LuaJIT FFI printf example on Apple silicon and read Apple's linked arm64 ABI notes; done means variadic printf arguments render correctly rather than producing garbage.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.