Skip to content

Usage of ffi not in luaJit #764

@sudheerhebbale

Description

@sudheerhebbale

In the file busted/luajit.lua

The presence of ffi as a module is tested using the following code

local isJit = (tostring(assert):match('builtin') ~= nil)

if not isJit then
  return function() end
end

This works well for luaJit, which is compatible with lua5.1; luaJit, however, is incompatible with later versions lua5.2, lua5.3 and lua5.4

To address this, I have been maintaining a ffi library https://github.com/Tekenlight/luaffifb which is a fork from https://github.com/facebook/luaffifb. This is supported on Linux x86_64 and ARM64 and OSX x86_64 and ARM64 platforms.

While testing a simple test case

With two identical files test1.lua and test2.lua with content:

local ffi = require "ffi"
describe("Test", function() end)

It is resulting in a core double free error as below

$ busted --lua=lua5.3 test1.lua test2.lua

0 successes / 0 failures / 0 errors / 0 pending : 0.003987 seconds
lua5.3(31915,0x208f460c0) malloc: Double free of object 0x120804b20
lua5.3(31915,0x208f460c0) malloc: *** set a breakpoint in malloc_error_break to debug

I have done a fix to this issue, in busted/luajit.lua module where the testing for existence of ffi is changed to look for external ffi libraries apart from luaJit only.

Can you please merge that PR and publish the fix on luarocks, if done it will help myself as well as other users of the library I have been maintaining.

The PR reference is #763

Thanks,

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