lua-users home
lua-l archive

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




On Saturday, 31 December 2011, Jeff Smith <spammealot1@live.co.uk> wrote:
> Hi
>  
> Thanks Roberto & Markus for the replies. As a quick workaround for the Swig issue I put an ugly macro into lauxlib.h
>  
> #define lua_pushvalue(L,LUA_GLOBALSINDEX)    lua_getglobal(L,"_G")
>
> This looks a valid fix to me, that meant I can now compile and link without errors.
>  
> Unfortunately, things are still a bit of a crashfest. I found one issue, but still suffering a crash after I fixed it.
>  
> Issue 1)
> I am running this 5.2 build on an oddball OS that hasnt got a realloc() function, so I had to write my own a while back. This new 5.2 showed up a weakness in my realloc implementation.
>  
> 5.2 does something rather odd though that presumably 5.1 didnt. The first time a memory alloc occurs
>  
>  static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
> The calling params are:  ptr=NULL, but osize=8   nsize=368
>  
> The oldsize param doesnt seem to really mean the old memory allocation block size any longer, its seems to be a LUA enum, 5,6,7,8 etc. I had used osize to decided if a memcpy was needed and was now causing a crash with 5.2. This was trivial to fix such that if ptr==NULL then it doesnt try and use osize now.
>  
> The Lua code is kind of confusing here though, why an enum ?
>  
> Issue 2)
> I still get a crash in the Swig auto generated code
>  
> SWIGEXPORT int SWIG_init(lua_State* L)
> {
>   int i;
>   /* start with global table */
>   lua_pushvalue(L,LUA_GLOBALSINDEX);
>   /* SWIG's internal initalisation */
>   SWIG_InitializeModule((void*)L);
>   SWIG_PropagateClientData();
>   /* add a global fn */
>   SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);                <-- !! Crashes here !!
>  
> where the swig add function is defined as
>  
> #define SWIG_Lua_add_function(L,n,f) \
>      (lua_pushstring(L, n), \
>       lua_pushcfunction(L, f), \
>       lua_rawset(L,-3))
> switching on the api check function seems to indicate its not finding the globals table on the stack
>  
> Assertion failed: (((((t))->u.i.tt__) == (0x7FF7A500 | (((5) | (1 << 6)))))) &&
> "table expected", file c:\lapi.c, line 781
>  
> which I guess puts doubt into the earlier LUA_GLOBALSINDEX fix is actually working ?
>  
> not sure how to make progress on this issue at the moment, any thoughts gratefully received
>  
> Regards Geoff
>  
>  
>  
>> Date: Thu, 29 Dec 2011 19:05:17 -0800
>> From: willhelm.schmid@googlemail.com
>> To: lua-l@lists.lua.org
>> Subject: Re: Lua 5.2 & SWIG compatibility problem
>>
>> Try this:
>>
>> -- Temporary swig hack. Convert from Lua 5.1 to 5.2
>> local function fixSwig(data)
>> data=""> >> data="">>> return data
>> end
>>
>

Your macro _fix_ is really not what you want. Why would you ask if the proposed changes where the best and then completly ignore the answer?

Liam