jmckaskill / luaffi

Standalone FFI library for calling C functions from lua. Compatible with the luajit FFI interface.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing test on Mac OS X

catwell opened this issue · comments

make test_macosx returns this:

make test_posix "SOCC=MACOSX_DEPLOYMENT_TARGET=10.3 cc -dynamiclib -single_module -undefined dynamic_lookup -fPIC"
MACOSX_DEPLOYMENT_TARGET=10.3 cc -dynamiclib -single_module -undefined dynamic_lookup -fPIC ffi.o ctype.o parser.o call.o -o ffi.so
LD_LIBRARY_PATH=./ lua test.lua
Running test
check   16  4
lua: test.lua:19: assertion failed!
stack traceback:
    [C]: in function 'assert'
    test.lua:19: in function 'check'
    test.lua:385: in main chunk
    [C]: in ?
make[1]: *** [test_posix] Error 1
make: *** [test_macosx] Error 2

32 or 64 bit, and what version of OS X?

64 bit, and OS X 10.7.5.

Got any chance to look at this one? Current git head still has the issue. I have also tested on a Montain Lion machine (10.8.5) and I could reproduce it so apparently it's on all 64 bit macs.

Note that it's not only that test, alignment is completely broken on OS X. Tests on the following lines also break: 469, 499, 510, 514, 517, 520 and 522.

I hit those myself a couple days ago. Commented out with "FT" for failing test.

385:    -- FT check(c.g_date.nYear, 4)
469:            -- FT checkalign(type, v, c['print_align_attr_def_' .. suffix](buf, v))
499:                -- FT check_align('struct bz_'..tnum..'_'..znum..'_'..bnum, '1 2 3', c['print_bz_'..tnum..'_'..znum..'_'..bnum](psz, palign, buf, {1,2,3}))
510:            -- FT check_align('struct ba_'..tnum..'_'..bnum, '1 2', c['print_ba_'..tnum..'_'..bnum](psz, palign, buf, {1,2}))
514:    -- FT check_align('struct Date', '1 2 3 4', c.print_date(psz, palign, buf, {1,2,3,4}))
517:    -- FT check_align('struct sysv2', '1 2 3 4 5 6', c.print_sysv2(psz, palign, buf, {1,2,3,4,5,6}))
520:    -- FT check_align('struct sysv5', '1 2 3', c.print_sysv5(psz, palign, buf, {1,2,3}))
522:    -- FT check_align('struct sysv7', '1 2 3 4 5', c.print_sysv7(psz, palign, buf, {1,2,3,4,5}))
852:-- FT x, y = pairs(v)
853:-- FT assert(x == 1 and y == 2)
854:-- FT x, y = ipairs(v)
855:-- FT assert(x == 2 and y == 3)

CPU: 8-core 64-bit sandybridge
OS X: 10.8.5-x86_64
Xcode: 5.0.1
CLT: 5.0.0.0.1.1377666378
GCC-4.2: build 5666
Clang: 5.0 build 500

In the test on line 385, I am not even sure how nYear is ever set to the value 4. Looks like most of the failing tests have to do with alignment (bitfields, structs)