lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Scratch that. I was trying to be smart and write you a whole test, while in the mean time making the bug go away :)

Here is the one that HANGS on Windows/x86. On Windows/x64 it prints out somewhat correctly (I would've expected the "asm" replacement to be written, but correct that it errors it):

luajit.exe: bug.lua:9: cannot resolve symbol 'winGetTickCount': The operation completed successfully.

stack traceback:
        [C]: in function '__index'
        bug.lua:9: in main chunk
        [C]: ?

THE CODE:
--------

assert( jit and jit.os == "Windows" and jit.arch == "x86", "The bug happens only on Windows/x86" )
local ffi = require( "ffi" )
local C = ffi.C
local K = ffi.load( "KERNEL32" )
local U = ffi.load( "USER32" )

print()
ffi.cdef( 'uint32_t __stdcall winGetTickCount(void) asm("GetTickCount12")' );
print( '3 C Hangs', C.winGetTickCount() )
print( '3 K Hangs', K.winGetTickCount() )
print( '3 U Hangs', U.winGetTickCount() )
print( '3 Never comes here (it hangs). Comment all of the previous three lines and it would come' )

--[[
#if LJ_TARGET_X86 && LJ_ABI_WIN
/* Compute argument size for fastcall/stdcall functions. */
static CTSize clib_func_argsize(CTState *cts, CType *ct)
{
  CTSize n = 0;
  while (ct->sib) {
    CType *d;
    ct = ctype_get(cts, ct->sib);
    lua_assert(ctype_isfield(ct->info));
    d = ctype_rawchild(cts, ct);
    n += ((d->size + 3) & ~3);
  }
  return n;
}
#endif
--]]


On 3/30/2012 9:43 PM, Dimiter 'malkia' Stanev wrote:
-- LuaJIT tag
--
-- commit bcd459aa0e5ab8e6df4a89c75c4f9f00ec7d0176
-- Author: Mike Pall <mike>
-- Date: Fri Mar 30 01:36:55 2012 +0200
--
-- MIPS: Integrate and enable JIT compiler.
--

assert( jit and jit.os == "Windows" and jit.arch == "x86", "The bug
happens only on Windows/x86" )
local ffi = require( "ffi" )
local C = ffi.C
local K = ffi.load( "KERNEL32" )
local U = ffi.load( "USER32" )

print()

ffi.cdef( 'uint32_t GetTickCount()' )
print( '1 C Works ', C.GetTickCount() )
print( '1 K Works ', K.GetTickCount() )
--print( '1 U should not work', U.GetTickCount() ) -- ERRORS OUT
NORMALLY AS IT SHOULD

ffi.cdef( 'uint32_t __stdcall GetTickCount()' )
print( '2 C Works ', C.GetTickCount() )
print( '2 K Works ', K.GetTickCount() )
--print( '2 U should not work', U.GetTickCount() ) -- ERRORS OUT
NORMALLY AS IT SHOULD

ffi.cdef( 'uint32_t winGetTickCount() asm("GetTickCount")' )
print( '3 C Works ', C.winGetTickCount() )
print( '3 K Works ', K.GetTickCount() )
print( '3 U Works ', U.GetTickCount() ) -- HANGS HERE!
print( '3 Never comes here (it hangs). Comment the previous line and it
would come' )

ffi.cdef( 'uint32_t __stdcall winGetTickCount() asm("GetTickCount")' )
print( 'Works ', C.winGetTickCount() )
print( '4 C Works ', C.winGetTickCount() )
print( '4 K Works ', K.GetTickCount() )
print( '4 U Works ', U.GetTickCount() ) -- HANGS HERE!
print( '4 Never comes here (it hangs). Comment the previous line and it
would come' )

--[[ - Never goes out of the loop
#if LJ_TARGET_X86 && LJ_ABI_WIN
/* Compute argument size for fastcall/stdcall functions. */
static CTSize clib_func_argsize(CTState *cts, CType *ct)
{
CTSize n = 0;
while (ct->sib) {
CType *d;
ct = ctype_get(cts, ct->sib);
lua_assert(ctype_isfield(ct->info));
d = ctype_rawchild(cts, ct);
n += ((d->size + 3) & ~3);
}
return n;
}
#endif
--]]