[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.1.2-rc5 now available
- From: "Jose Luis Hidalgo" <joseluis.hidalgo@...>
- Date: Fri, 30 Mar 2007 20:55:02 +0200
Hi Luiz,
2007/3/30, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
> Is there any chance that you can reconsider what we've talked about:
> http://lua-users.org/lists/lua-l/2006-11/msg00174.html
Not now, because this is not a bug. Also, I'm still not convinced that
using RTLD_GLOBAL is a good thing, on the contrary, and others seemed
to agree. Your application has quite specific needs.
Well, from the mail:
http://lua-users.org/lists/lua-l/2006-11/msg00210.html
Let's remember that gcc since 3.0 version uses address comparisons to
determine type equality, so a very big part of the C++ RTTI mechanism
( typeid, dynamic_casts, ...) relies on this. I've made a test, you
can download here:
http://www.pplux.com/files/lua_RTTI_test.tgz
Basically there is a type "Common<class T>", and as a template it is
implemented in the header of "common.hpp", two fictitious libraries
"m1" and "m2" use the "common" library and instances the template with
a float. Actually, Common<float> should be the SAME type in both
dll... but it is not because how libraries where loaded.
This will not be a very big deal, but in Windows lua has the correct
behavior, (in windows the type check is not done based on the typeid
pointers). So, for me, different non portable behaviors between
platforms is some kind of bug...
This is the Example (lua code) :
require("m1") -- loads m1
require("m2") -- loads m2
print(m1.info()) -- info about common<float> type (at m1)
print(m2.info()) -- info about common<float> type (at m2)
obj1 = m1.get() -- get the typeid(common<float>) from m1
obj2 = m2.get() -- get the typeid(common<float>) from m2
m2.check(obj1) -- check if typeid are the same (at m2 lib), should be
"1" for correct RTTI
m1.check(obj2) -- check if tyepid are the same (at m1 lib)
This is the output :
************************************************************
On Windows ( VS8/lua/lua5.1.exe )
************************************************************
Lua 5.1.1 Copyright (C) 1994-2006 Lua.org, PUC-Rio
dofile("../../test.lua")
Creating an object...
Creating an object...
m1:typeid = 003AC04C typename = class Common<float> * Base = 003AC06C
m2:typeid = 0043C04C typename = class Common<float> * Base = 0043C06C
Check = 1
Check = 1
************************************************************
On Linux standard lua
************************************************************
Creating an object...
Creating an object...
m1:typeid = 0xb7eeb79c typename = P6CommonIfE Base = 0xb7eeb794
m2:typeid = 0xb7cef79c typename = P6CommonIfE Base = 0xb7cef794
Check = 0
Check = 0
************************************************************
On Linux modified lua (RTLD_GLOBAL)
************************************************************
Creating an object...
Creating an object...
m1:typeid = 0xb7fa879c typename = P6CommonIfE Base = 0xb7fa8794
m1:typeid = 0xb7fa879c typename = P6CommonIfE Base = 0xb7fa8794
Check = 1
Check = 1
The "Checks" are comparisons between the same types from m1.so ->
m2.so and from m2.so -> m1.so ... "0" means they are not the same
type, "1" means they are. As you can see, the vanilla lua interpreter
in windows has not the same behavior as Linux, but adding the
RTLD_GLOBAL everything is correct at both platforms.
Cheers,
Jose L.
--
Jose L. Hidalgo Valiño (PpluX)
---- http://www.pplux.com ----