Static lib and lua5.1.dll (crash on lua_close_())

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Static lib and lua5.1.dll (crash on lua_close_())

Mark Mruss
Hi Everyone,

I asked this in a separate email, but I thought that it might get more
traction if I ask it by itself.

Does anyone know what the bjam commands would be to compile luabind as
a static library that links against the lua dll?

I'm getting a crashe on lua_close() and it smells like the crashes
that one gets when there are two instances of the lua runtime being
used.

I can get my application to crash as long as I call:

luabind::open(pLuaState);

luabind appears to be working, but when the program closes I always
get a crash, whether I bind to any of my C++ or not (as long as I have
the above call).

I'm using the following in a bat file to compile luabind:

"C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
toolset=msvc-9.0 runtime-link=static link=static threading=multi
--debug-build define=LUA_BUILD_AS_DLL define=_MBCS

Am I crazy? Am I doing something wrong? Any help would be appreciated
as I would like to use luabind but I keep running into road blocks.

mark.

------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Mark Mruss
Hi Everyone,

I'm not sure that there is anyone else around as I haven't had a
response to any of my last three emails but this is where the crash is
coming from:

In:

LUA_API void lua_close (lua_State *L) {

The line:

while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);

Which (after drilling all the way down) get to:

int luaD_precall (lua_State *L, StkId func, int nresults) {

And then the crash seems to happen around:

lua_unlock(L);
n = (*curr_func(L)->c.f)(L);  /* do the actual call */

Does this seem familiar to anyone else? Does anyone have any ideas
about this crash and how it relates to laubind?

If I do not open luabind then the crash does not happen.

Thanks (if there is anyone out there),

mark.



On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]> wrote:

> Hi Everyone,
>
> I asked this in a separate email, but I thought that it might get more
> traction if I ask it by itself.
>
> Does anyone know what the bjam commands would be to compile luabind as
> a static library that links against the lua dll?
>
> I'm getting a crashe on lua_close() and it smells like the crashes
> that one gets when there are two instances of the lua runtime being
> used.
>
> I can get my application to crash as long as I call:
>
> luabind::open(pLuaState);
>
> luabind appears to be working, but when the program closes I always
> get a crash, whether I bind to any of my C++ or not (as long as I have
> the above call).
>
> I'm using the following in a bat file to compile luabind:
>
> "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
> toolset=msvc-9.0 runtime-link=static link=static threading=multi
> --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>
> Am I crazy? Am I doing something wrong? Any help would be appreciated
> as I would like to use luabind but I keep running into road blocks.
>
> mark.
>

------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Kristoffer Danielsson
Just guessing here, but is this a multi-threaded application? Really weird crashes might occur if lua is used erroneously in a multithreaded application.
 

> Date: Fri, 14 May 2010 15:54:17 -0500
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
>
> Hi Everyone,
>
> I'm not sure that there is anyone else around as I haven't had a
> response to any of my last three emails but this is where the crash is
> coming from:
>
> In:
>
> LUA_API void lua_close (lua_State *L) {
>
> The line:
>
> while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
>
> Which (after drilling all the way down) get to:
>
> int luaD_precall (lua_State *L, StkId func, int nresults) {
>
> And then the crash seems to happen around:
>
> lua_unlock(L);
> n = (*curr_func(L)->c.f)(L); /* do the actual call */
>
> Does this seem familiar to anyone else? Does anyone have any ideas
> about this crash and how it relates to laubind?
>
> If I do not open luabind then the crash does not happen.
>
> Thanks (if there is anyone out there),
>
> mark.
>
>
>
> On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]> wrote:
> > Hi Everyone,
> >
> > I asked this in a separate email, but I thought that it might get more
> > traction if I ask it by itself.
> >
> > Does anyone know what the bjam commands would be to compile luabind as
> > a static library that links against the lua dll?
> >
> > I'm getting a crashe on lua_close() and it smells like the crashes
> > that one gets when there are two instances of the lua runtime being
> > used.
> >
> > I can get my application to crash as long as I call:
> >
> > luabind::open(pLuaState);
> >
> > luabind appears to be working, but when the program closes I always
> > get a crash, whether I bind to any of my C++ or not (as long as I have
> > the above call).
> >
> > I'm using the following in a bat file to compile luabind:
> >
> > "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
> > toolset=msvc-9.0 runtime-link=static link=static threading=multi
> > --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
> >
> > Am I crazy? Am I doing something wrong? Any help would be appreciated
> > as I would like to use luabind but I keep running into road blocks.
> >
> > mark.
> >
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user


Chatta från inkorgen. Se möjligheterna med Hotmail! Klicka här!
------------------------------------------------------------------------------


_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Mark Mruss
Hi Kristoffer,

Yes this is a multi-threaded application, in reality there is only one
main thread and there should only be one instance of the lua runtime.
(shared dll)

I'm actually using luabind in a dll that will be loaded by my main
application. I've tried to set all of the compile settings so that the
luabind.lib matches the compile settings that I used to compile lua,
but so far all I get are crashes.

I can load lua dll modules without any problems so I think that using
luabind in a dll should work.

mark.

On Fri, May 14, 2010 at 3:57 PM, Kristoffer Danielsson
<[hidden email]> wrote:

> Just guessing here, but is this a multi-threaded application? Really weird
> crashes might occur if lua is used erroneously in a multithreaded
> application.
>
>> Date: Fri, 14 May 2010 15:54:17 -0500
>> From: [hidden email]
>> To: [hidden email]
>> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
>>
>> Hi Everyone,
>>
>> I'm not sure that there is anyone else around as I haven't had a
>> response to any of my last three emails but this is where the crash is
>> coming from:
>>
>> In:
>>
>> LUA_API void lua_close (lua_State *L) {
>>
>> The line:
>>
>> while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
>>
>> Which (after drilling all the way down) get to:
>>
>> int luaD_precall (lua_State *L, StkId func, int nresults) {
>>
>> And then the crash seems to happen around:
>>
>> lua_unlock(L);
>> n = (*curr_func(L)->c.f)(L); /* do the actual call */
>>
>> Does this seem familiar to anyone else? Does anyone have any ideas
>> about this crash and how it relates to laubind?
>>
>> If I do not open luabind then the crash does not happen.
>>
>> Thanks (if there is anyone out there),
>>
>> mark.
>>
>>
>>
>> On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]> wrote:
>> > Hi Everyone,
>> >
>> > I asked this in a separate email, but I thought that it might get more
>> > traction if I ask it by itself.
>> >
>> > Does anyone know what the bjam commands would be to compile luabind as
>> > a static library that links against the lua dll?
>> >
>> > I'm getting a crashe on lua_close() and it smells like the crashes
>> > that one gets when there are two instances of the lua runtime being
>> > used.
>> >
>> > I can get my application to crash as long as I call:
>> >
>> > luabind::open(pLuaState);
>> >
>> > luabind appears to be working, but when the program closes I always
>> > get a crash, whether I bind to any of my C++ or not (as long as I have
>> > the above call).
>> >
>> > I'm using the following in a bat file to compile luabind:
>> >
>> > "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
>> > toolset=msvc-9.0 runtime-link=static link=static threading=multi
>> > --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>> >
>> > Am I crazy? Am I doing something wrong? Any help would be appreciated
>> > as I would like to use luabind but I keep running into road blocks.
>> >
>> > mark.
>> >
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> luabind-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
> ________________________________
> Chatta från inkorgen. Se möjligheterna med Hotmail! Klicka här!
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>

------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Nigel Atkinson-2
I was about to suggest that your Lua dll and luabind/your program might
be using differing versions of the CRT, but if you have made sure the
compiler settings for each are identical, that is probably not the case.

You could always try using Lua as a static lib perhaps.  Even just to
see if it fixes your bug.  It's as easy as dropping most of the Lua
source into your project.

Nigel

On Mon, 2010-05-17 at 11:48 -0500, Mark Mruss wrote:

> Hi Kristoffer,
>
> Yes this is a multi-threaded application, in reality there is only one
> main thread and there should only be one instance of the lua runtime.
> (shared dll)
>
> I'm actually using luabind in a dll that will be loaded by my main
> application. I've tried to set all of the compile settings so that the
> luabind.lib matches the compile settings that I used to compile lua,
> but so far all I get are crashes.
>
> I can load lua dll modules without any problems so I think that using
> luabind in a dll should work.
>
> mark.
>
> On Fri, May 14, 2010 at 3:57 PM, Kristoffer Danielsson
> <[hidden email]> wrote:
> > Just guessing here, but is this a multi-threaded application? Really weird
> > crashes might occur if lua is used erroneously in a multithreaded
> > application.
> >
> >> Date: Fri, 14 May 2010 15:54:17 -0500
> >> From: [hidden email]
> >> To: [hidden email]
> >> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
> >>
> >> Hi Everyone,
> >>
> >> I'm not sure that there is anyone else around as I haven't had a
> >> response to any of my last three emails but this is where the crash is
> >> coming from:
> >>
> >> In:
> >>
> >> LUA_API void lua_close (lua_State *L) {
> >>
> >> The line:
> >>
> >> while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
> >>
> >> Which (after drilling all the way down) get to:
> >>
> >> int luaD_precall (lua_State *L, StkId func, int nresults) {
> >>
> >> And then the crash seems to happen around:
> >>
> >> lua_unlock(L);
> >> n = (*curr_func(L)->c.f)(L); /* do the actual call */
> >>
> >> Does this seem familiar to anyone else? Does anyone have any ideas
> >> about this crash and how it relates to laubind?
> >>
> >> If I do not open luabind then the crash does not happen.
> >>
> >> Thanks (if there is anyone out there),
> >>
> >> mark.
> >>
> >>
> >>
> >> On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]> wrote:
> >> > Hi Everyone,
> >> >
> >> > I asked this in a separate email, but I thought that it might get more
> >> > traction if I ask it by itself.
> >> >
> >> > Does anyone know what the bjam commands would be to compile luabind as
> >> > a static library that links against the lua dll?
> >> >
> >> > I'm getting a crashe on lua_close() and it smells like the crashes
> >> > that one gets when there are two instances of the lua runtime being
> >> > used.
> >> >
> >> > I can get my application to crash as long as I call:
> >> >
> >> > luabind::open(pLuaState);
> >> >
> >> > luabind appears to be working, but when the program closes I always
> >> > get a crash, whether I bind to any of my C++ or not (as long as I have
> >> > the above call).
> >> >
> >> > I'm using the following in a bat file to compile luabind:
> >> >
> >> > "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
> >> > toolset=msvc-9.0 runtime-link=static link=static threading=multi
> >> > --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
> >> >
> >> > Am I crazy? Am I doing something wrong? Any help would be appreciated
> >> > as I would like to use luabind but I keep running into road blocks.
> >> >
> >> > mark.
> >> >
> >>
> >>
> >> ------------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> luabind-user mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/luabind-user
> >
> > ________________________________
> > Chatta från inkorgen. Se möjligheterna med Hotmail! Klicka här!
> > ------------------------------------------------------------------------------
> >
> >
> > _______________________________________________
> > luabind-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/luabind-user
> >
> >
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Kristoffer Danielsson
Beware of _SECURE_SCL=0 setting!
http://msdn.microsoft.com/en-us/library/aa985896(VS.80).aspx
 

> From: [hidden email]
> To: [hidden email]
> Date: Tue, 18 May 2010 07:28:24 +1200
> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
>
> I was about to suggest that your Lua dll and luabind/your program might
> be using differing versions of the CRT, but if you have made sure the
> compiler settings for each are identical, that is probably not the case.
>
> You could always try using Lua as a static lib perhaps. Even just to
> see if it fixes your bug. It's as easy as dropping most of the Lua
> source into your project.
>
> Nigel
>
> On Mon, 2010-05-17 at 11:48 -0500, Mark Mruss wrote:
> > Hi Kristoffer,
> >
> > Yes this is a multi-threaded application, in reality there is only one
> > main thread and there should only be one instance of the lua runtime.
> > (shared dll)
> >
> > I'm actually using luabind in a dll that will be loaded by my main
> > application. I've tried to set all of the compile settings so that the
> > luabind.lib matches the compile settings that I used to compile lua,
> > but so far all I get are crashes.
> >
> > I can load lua dll modules without any problems so I think that using
> > luabind in a dll should work.
> >
> > mark.
> >
> > On Fri, May 14, 2010 at 3:57 PM, Kristoffer Danielsson
> > <[hidden email]> wrote:
> > > Just guessing here, but is this a multi-threaded application? Really weird
> > > crashes might occur if lua is used erroneously in a multithreaded
> > > application.
> > >
> > >> Date: Fri, 14 May 2010 15:54:17 -0500
> > >> From: [hidden email]
> > >> To: [hidden email]
> > >> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
> > >>
> > >> Hi Everyone,
> > >>
> > >> I'm not sure that there is anyone else around as I haven't had a
> > >> response to any of my last three emails but this is where the crash is
> > >> coming from:
> > >>
> > >> In:
> > >>
> > >> LUA_API void lua_close (lua_State *L) {
> > >>
> > >> The line:
> > >>
> > >> while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
> > >>
> > >> Which (after drilling all the way down) get to:
> > >>
> > >> int luaD_precall (lua_State *L, StkId func, int nresults) {
> > >>
> > >> And then the crash seems to happen around:
> > >>
> > >> lua_unlock(L);
> > >> n = (*curr_func(L)->c.f)(L); /* do the actual call */
> > >>
> > >> Does this seem familiar to anyone else? Does anyone have any ideas
> > >> about this crash and how it relates to laubind?
> > >>
> > >> If I do not open luabind then the crash does not happen.
> > >>
> > >> Thanks (if there is anyone out there),
> > >>
> > >> mark.
> > >>
> > >>
> > >>
> > >> On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]> wrote:
> > >> > Hi Everyone,
> > >> >
> > >> > I asked this in a separate email, but I thought that it might get more
> > >> > traction if I ask it by itself.
> > >> >
> > >> > Does anyone know what the bjam commands would be to compile luabind as
> > >> > a static library that links against the lua dll?
> > >> >
> > >> > I'm getting a crashe on lua_close() and it smells like the crashes
> > >> > that one gets when there are two instances of the lua runtime being
> > >> > used.
> > >> >
> > >> > I can get my application to crash as long as I call:
> > >> >
> > >> > luabind::open(pLuaState);
> > >> >
> > >> > luabind appears to be working, but when the program closes I always
> > >> > get a crash, whether I bind to any of my C++ or not (as long as I have
> > >> > the above call).
> > >> >
> > >> > I'm using the following in a bat file to compile luabind:
> > >> >
> > >> > "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
> > >> > toolset=msvc-9.0 runtime-link=static link=static threading=multi
> > >> > --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
> > >> >
> > >> > Am I crazy? Am I doing something wrong? Any help would be appreciated
> > >> > as I would like to use luabind but I keep running into road blocks.
> > >> >
> > >> > mark.
> > >> >
> > >>
> > >>
> > >> ------------------------------------------------------------------------------
> > >>
> > >> _______________________________________________
> > >> luabind-user mailing list
> > >> [hidden email]
> > >> https://lists.sourceforge.net/lists/listinfo/luabind-user
> > >
> > > ________________________________
> > > Chatta från inkorgen. Se möjligheterna med Hotmail! Klicka här!
> > > ------------------------------------------------------------------------------
> > >
> > >
> > > _______________________________________________
> > > luabind-user mailing list
> > > [hidden email]
> > > https://lists.sourceforge.net/lists/listinfo/luabind-user
> > >
> > >
> >
> > ------------------------------------------------------------------------------
> >
> > _______________________________________________
> > luabind-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user


Ladda ner världens mest använda webbläsare nu. Ta med dig Hotmail i mobilen!
------------------------------------------------------------------------------


_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Mark Mruss
Nigel:

This is the commandline that I used when compiling the lua DLL:

/Od /I "../include" /D "_CRT_SECURE_NO_DEPRECATE" /D "DEBUG" /D
"MSVC9" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1 /MT /Gy
/Fo"../obj/lua5.1_dll/Debug\\" /Fd"../obj/lua5.1_dll/Debug\vc90.pdb"
/W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt

This is the bjam command that I use to compile luabind:


"C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
toolset=msvc-9.0 runtime-link=static link=static threading=multi
--debug-build define=LUA_BUILD_AS_DLL define=_MBCS

And funally this is what I use to compile my dll:

/Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_USRDLL" /D "_WINDLL" /D
"_MBCS" /Gm /EHsc /RTC1 /MTd /Yu"stdafx.h" /Fp"Debug\CVSList.pch"
/Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP
/errorReport:prompt

Maybe I'm missing something but I think things are compatible?

Kristoffer:

Should I set _SECURE_SCL=1 or just leave it as the default for now?
I'm not using iterators in my code, but maybe it's something for
laubind.

Thanks for the answers everyone, hopefully I'll be able to get it
working. Sorry if I'm missing something obvious.

mark.

On Tue, May 18, 2010 at 3:42 AM, Kristoffer Danielsson
<[hidden email]> wrote:

> Beware of _SECURE_SCL=0 setting!
> http://msdn.microsoft.com/en-us/library/aa985896(VS.80).aspx
>
>> From: [hidden email]
>> To: [hidden email]
>> Date: Tue, 18 May 2010 07:28:24 +1200
>> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
>>
>> I was about to suggest that your Lua dll and luabind/your program might
>> be using differing versions of the CRT, but if you have made sure the
>> compiler settings for each are identical, that is probably not the case.
>>
>> You could always try using Lua as a static lib perhaps. Even just to
>> see if it fixes your bug. It's as easy as dropping most of the Lua
>> source into your project.
>>
>> Nigel
>>
>> On Mon, 2010-05-17 at 11:48 -0500, Mark Mruss wrote:
>> > Hi Kristoffer,
>> >
>> > Yes this is a multi-threaded application, in reality there is only one
>> > main thread and there should only be one instance of the lua runtime.
>> > (shared dll)
>> >
>> > I'm actually using luabind in a dll that will be loaded by my main
>> > application. I've tried to set all of the compile settings so that the
>> > luabind.lib matches the compile settings that I used to compile lua,
>> > but so far all I get are crashes.
>> >
>> > I can load lua dll modules without any problems so I think that using
>> > luabind in a dll should work.
>> >
>> > mark.
>> >
>> > On Fri, May 14, 2010 at 3:57 PM, Kristoffer Danielsson
>> > <[hidden email]> wrote:
>> > > Just guessing here, but is this a multi-threaded application? Really
>> > > weird
>> > > crashes might occur if lua is used erroneously in a multithreaded
>> > > application.
>> > >
>> > >> Date: Fri, 14 May 2010 15:54:17 -0500
>> > >> From: [hidden email]
>> > >> To: [hidden email]
>> > >> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on
>> > >> lua_close_())
>> > >>
>> > >> Hi Everyone,
>> > >>
>> > >> I'm not sure that there is anyone else around as I haven't had a
>> > >> response to any of my last three emails but this is where the crash
>> > >> is
>> > >> coming from:
>> > >>
>> > >> In:
>> > >>
>> > >> LUA_API void lua_close (lua_State *L) {
>> > >>
>> > >> The line:
>> > >>
>> > >> while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
>> > >>
>> > >> Which (after drilling all the way down) get to:
>> > >>
>> > >> int luaD_precall (lua_State *L, StkId func, int nresults) {
>> > >>
>> > >> And then the crash seems to happen around:
>> > >>
>> > >> lua_unlock(L);
>> > >> n = (*curr_func(L)->c.f)(L); /* do the actual call */
>> > >>
>> > >> Does this seem familiar to anyone else? Does anyone have any ideas
>> > >> about this crash and how it relates to laubind?
>> > >>
>> > >> If I do not open luabind then the crash does not happen.
>> > >>
>> > >> Thanks (if there is anyone out there),
>> > >>
>> > >> mark.
>> > >>
>> > >>
>> > >>
>> > >> On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]> wrote:
>> > >> > Hi Everyone,
>> > >> >
>> > >> > I asked this in a separate email, but I thought that it might get
>> > >> > more
>> > >> > traction if I ask it by itself.
>> > >> >
>> > >> > Does anyone know what the bjam commands would be to compile luabind
>> > >> > as
>> > >> > a static library that links against the lua dll?
>> > >> >
>> > >> > I'm getting a crashe on lua_close() and it smells like the crashes
>> > >> > that one gets when there are two instances of the lua runtime being
>> > >> > used.
>> > >> >
>> > >> > I can get my application to crash as long as I call:
>> > >> >
>> > >> > luabind::open(pLuaState);
>> > >> >
>> > >> > luabind appears to be working, but when the program closes I always
>> > >> > get a crash, whether I bind to any of my C++ or not (as long as I
>> > >> > have
>> > >> > the above call).
>> > >> >
>> > >> > I'm using the following in a bat file to compile luabind:
>> > >> >
>> > >> > "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
>> > >> > toolset=msvc-9.0 runtime-link=static link=static threading=multi
>> > >> > --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>> > >> >
>> > >> > Am I crazy? Am I doing something wrong? Any help would be
>> > >> > appreciated
>> > >> > as I would like to use luabind but I keep running into road blocks.
>> > >> >
>> > >> > mark.
>> > >> >
>> > >>
>> > >>
>> > >>
>> > >> ------------------------------------------------------------------------------
>> > >>
>> > >> _______________________________________________
>> > >> luabind-user mailing list
>> > >> [hidden email]
>> > >> https://lists.sourceforge.net/lists/listinfo/luabind-user
>> > >
>> > > ________________________________
>> > > Chatta från inkorgen. Se möjligheterna med Hotmail! Klicka här!
>> > >
>> > > ------------------------------------------------------------------------------
>> > >
>> > >
>> > > _______________________________________________
>> > > luabind-user mailing list
>> > > [hidden email]
>> > > https://lists.sourceforge.net/lists/listinfo/luabind-user
>> > >
>> > >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > luabind-user mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/luabind-user
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> luabind-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
> ________________________________
> Ladda ner världens mest använda webbläsare nu. Ta med dig Hotmail i mobilen!
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>

------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Kristoffer Danielsson
Make sure you set _SECURE_SCL=0 in release mode. Otherwise you get a huge performance hit on your iterators! In debug-mode you should leave it set to _SECURE_SCL=1.
 
Something like this:
bjam --toolset=msvc-9.0 --build-type=complete release/define=_SECURE_SCL=0 debug/define=_SECURE_SCL=1 --stagedir=stage stage

 

> Date: Tue, 18 May 2010 11:57:33 -0500
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
>
> Nigel:
>
> This is the commandline that I used when compiling the lua DLL:
>
> /Od /I "../include" /D "_CRT_SECURE_NO_DEPRECATE" /D "DEBUG" /D
> "MSVC9" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1 /MT /Gy
> /Fo"../obj/lua5.1_dll/Debug\\" /Fd"../obj/lua5.1_dll/Debug\vc90.pdb"
> /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt
>
> This is the bjam command that I use to compile luabind:
>
>
> "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
> toolset=msvc-9.0 runtime-link=static link=static threading=multi
> --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>
> And funally this is what I use to compile my dll:
>
> /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_USRDLL" /D "_WINDLL" /D
> "_MBCS" /Gm /EHsc /RTC1 /MTd /Yu"stdafx.h" /Fp"Debug\CVSList.pch"
> /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP
> /errorReport:prompt
>
> Maybe I'm missing something but I think things are compatible?
>
> Kristoffer:
>
> Should I set _SECURE_SCL=1 or just leave it as the default for now?
> I'm not using iterators in my code, but maybe it's something for
> laubind.
>
> Thanks for the answers everyone, hopefully I'll be able to get it
> working. Sorry if I'm missing something obvious.
>
> mark.
>
> On Tue, May 18, 2010 at 3:42 AM, Kristoffer Danielsson
> <[hidden email]> wrote:
> > Beware of _SECURE_SCL=0 setting!
> > http://msdn.microsoft.com/en-us/library/aa985896(VS.80).aspx
> >
> >> From: [hidden email]
> >> To: [hidden email]
> >> Date: Tue, 18 May 2010 07:28:24 +1200
> >> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
> >>
> >> I was about to suggest that your Lua dll and luabind/your program might
> >> be using differing versions of the CRT, but if you have made sure the
> >> compiler settings for each are identical, that is probably not the case.
> >>
> >> You could always try using Lua as a static lib perhaps. Even just to
> >> see if it fixes your bug. It's as easy as dropping most of the Lua
> >> source into your project.
> >>
> >> Nigel
> >>
> >> On Mon, 2010-05-17 at 11:48 -0500, Mark Mruss wrote:
> >> > Hi Kristoffer,
> >> >
> >> > Yes this is a multi-threaded application, in reality there is only one
> >> > main thread and there should only be one instance of the lua runtime.
> >> > (shared dll)
> >> >
> >> > I'm actually using luabind in a dll that will be loaded by my main
> >> > application. I've tried to set all of the compile settings so that the
> >> > luabind.lib matches the compile settings that I used to compile lua,
> >> > but so far all I get are crashes.
> >> >
> >> > I can load lua dll modules without any problems so I think that using
> >> > luabind in a dll should work.
> >> >
> >> > mark.
> >> >
> >> > On Fri, May 14, 2010 at 3:57 PM, Kristoffer Danielsson
> >> > <[hidden email]> wrote:
> >> > > Just guessing here, but is this a multi-threaded application? Really
> >> > > weird
> >> > > crashes might occur if lua is used erroneously in a multithreaded
> >> > > application.
> >> > >
> >> > >> Date: Fri, 14 May 2010 15:54:17 -0500
> >> > >> From: [hidden email]
> >> > >> To: [hidden email]
> >> > >> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on
> >> > >> lua_close_())
> >> > >>
> >> > >> Hi Everyone,
> >> > >>
> >> > >> I'm not sure that there is anyone else around as I haven't had a
> >> > >> response to any of my last three emails but this is where the crash
> >> > >> is
> >> > >> coming from:
> >> > >>
> >> > >> In:
> >> > >>
> >> > >> LUA_API void lua_close (lua_State *L) {
> >> > >>
> >> > >> The line:
> >> > >>
> >> > >> while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
> >> > >>
> >> > >> Which (after drilling all the way down) get to:
> >> > >>
> >> > >> int luaD_precall (lua_State *L, StkId func, int nresults) {
> >> > >>
> >> > >> And then the crash seems to happen around:
> >> > >>
> >> > >> lua_unlock(L);
> >> > >> n = (*curr_func(L)->c.f)(L); /* do the actual call */
> >> > >>
> >> > >> Does this seem familiar to anyone else? Does anyone have any ideas
> >> > >> about this crash and how it relates to laubind?
> >> > >>
> >> > >> If I do not open luabind then the crash does not happen.
> >> > >>
> >> > >> Thanks (if there is anyone out there),
> >> > >>
> >> > >> mark.
> >> > >>
> >> > >>
> >> > >>
> >> > >> On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]> wrote:
> >> > >> > Hi Everyone,
> >> > >> >
> >> > >> > I asked this in a separate email, but I thought that it might get
> >> > >> > more
> >> > >> > traction if I ask it by itself.
> >> > >> >
> >> > >> > Does anyone know what the bjam commands would be to compile luabind
> >> > >> > as
> >> > >> > a static library that links against the lua dll?
> >> > >> >
> >> > >> > I'm getting a crashe on lua_close() and it smells like the crashes
> >> > >> > that one gets when there are two instances of the lua runtime being
> >> > >> > used.
> >> > >> >
> >> > >> > I can get my application to crash as long as I call:
> >> > >> >
> >> > >> > luabind::open(pLuaState);
> >> > >> >
> >> > >> > luabind appears to be working, but when the program closes I always
> >> > >> > get a crash, whether I bind to any of my C++ or not (as long as I
> >> > >> > have
> >> > >> > the above call).
> >> > >> >
> >> > >> > I'm using the following in a bat file to compile luabind:
> >> > >> >
> >> > >> > "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
> >> > >> > toolset=msvc-9.0 runtime-link=static link=static threading=multi
> >> > >> > --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
> >> > >> >
> >> > >> > Am I crazy? Am I doing something wrong? Any help would be
> >> > >> > appreciated
> >> > >> > as I would like to use luabind but I keep running into road blocks.
> >> > >> >
> >> > >> > mark.
> >> > >> >
> >> > >>
> >> > >>
> >> > >>
> >> > >> ------------------------------------------------------------------------------
> >> > >>
> >> > >> _______________________________________________
> >> > >> luabind-user mailing list
> >> > >> [hidden email]
> >> > >> https://lists.sourceforge.net/lists/listinfo/luabind-user
> >> > >
> >> > > ________________________________
> >> > > Chatta från inkorgen. Se möjligheterna med Hotmail! Klicka här!
> >> > >
> >> > > ------------------------------------------------------------------------------
> >> > >
> >> > >
> >> > > _______________________________________________
> >> > > luabind-user mailing list
> >> > > [hidden email]
> >> > > https://lists.sourceforge.net/lists/listinfo/luabind-user
> >> > >
> >> > >
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> >
> >> > _______________________________________________
> >> > luabind-user mailing list
> >> > [hidden email]
> >> > https://lists.sourceforge.net/lists/listinfo/luabind-user
> >>
> >>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> luabind-user mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/luabind-user
> >
> > ________________________________
> > Ladda ner världens mest använda webbläsare nu. Ta med dig Hotmail i mobilen!
> > ------------------------------------------------------------------------------
> >
> >
> > _______________________________________________
> > luabind-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/luabind-user
> >
> >
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user


Alla mejlkonton på ett ställe. Se möjligheterna med Hotmail! Internet Explorer 8
------------------------------------------------------------------------------


_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Catherine West
In reply to this post by Mark Mruss
This sounds kinda similar to a problem I was having a while ago on OS X that turned out to be caused by duplicate symbols.

I was doing the opposite of what you were doing... lua was built as a static library, and luabind was being built shared.

There seemed to be duplicate per library static variables in the lua library that were included in both my final binary (linked to the static lua library) and luabind (shared library, linked to the static lua library)

The duplicate static variables seemed to be garbage collector related, and normally my app would crash on shutdown, but I could get it to crash earlier by calling collectGarbage() in lua.

I *think* I did my analysis correctly, but I may not fully understand all the rules for the scope of static variables when it comes to the linker on different compilers / OSes.

I second the suggestion to try linking lua statically, as that eliminates the potential for duplicate per shared library symbols.

I hope you can get it figured out!
-Catherine

On May 18, 2010, at 11:57 AM, Mark Mruss wrote:

> Nigel:
>
> This is the commandline that I used when compiling the lua DLL:
>
> /Od /I "../include" /D "_CRT_SECURE_NO_DEPRECATE" /D "DEBUG" /D
> "MSVC9" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1 /MT /Gy
> /Fo"../obj/lua5.1_dll/Debug\\" /Fd"../obj/lua5.1_dll/Debug\vc90.pdb"
> /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt
>
> This is the bjam command that I use to compile luabind:
>
>
> "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
> toolset=msvc-9.0 runtime-link=static link=static threading=multi
> --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>
> And funally this is what I use to compile my dll:
>
> /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_USRDLL" /D "_WINDLL" /D
> "_MBCS" /Gm /EHsc /RTC1 /MTd /Yu"stdafx.h" /Fp"Debug\CVSList.pch"
> /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP
> /errorReport:prompt
>
> Maybe I'm missing something but I think things are compatible?
>
> Kristoffer:
>
> Should I set _SECURE_SCL=1 or just leave it as the default for now?
> I'm not using iterators in my code, but maybe it's something for
> laubind.
>
> Thanks for the answers everyone, hopefully I'll be able to get it
> working. Sorry if I'm missing something obvious.
>
> mark.
>
> On Tue, May 18, 2010 at 3:42 AM, Kristoffer Danielsson
> <[hidden email]> wrote:
>> Beware of _SECURE_SCL=0 setting!
>> http://msdn.microsoft.com/en-us/library/aa985896(VS.80).aspx
>>
>>> From: [hidden email]
>>> To: [hidden email]
>>> Date: Tue, 18 May 2010 07:28:24 +1200
>>> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
>>>
>>> I was about to suggest that your Lua dll and luabind/your program might
>>> be using differing versions of the CRT, but if you have made sure the
>>> compiler settings for each are identical, that is probably not the case.
>>>
>>> You could always try using Lua as a static lib perhaps. Even just to
>>> see if it fixes your bug. It's as easy as dropping most of the Lua
>>> source into your project.
>>>
>>> Nigel
>>>
>>> On Mon, 2010-05-17 at 11:48 -0500, Mark Mruss wrote:
>>>> Hi Kristoffer,
>>>>
>>>> Yes this is a multi-threaded application, in reality there is only one
>>>> main thread and there should only be one instance of the lua runtime.
>>>> (shared dll)
>>>>
>>>> I'm actually using luabind in a dll that will be loaded by my main
>>>> application. I've tried to set all of the compile settings so that the
>>>> luabind.lib matches the compile settings that I used to compile lua,
>>>> but so far all I get are crashes.
>>>>
>>>> I can load lua dll modules without any problems so I think that using
>>>> luabind in a dll should work.
>>>>
>>>> mark.
>>>>
>>>> On Fri, May 14, 2010 at 3:57 PM, Kristoffer Danielsson
>>>> <[hidden email]> wrote:
>>>>> Just guessing here, but is this a multi-threaded application? Really
>>>>> weird
>>>>> crashes might occur if lua is used erroneously in a multithreaded
>>>>> application.
>>>>>
>>>>>> Date: Fri, 14 May 2010 15:54:17 -0500
>>>>>> From: [hidden email]
>>>>>> To: [hidden email]
>>>>>> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on
>>>>>> lua_close_())
>>>>>>
>>>>>> Hi Everyone,
>>>>>>
>>>>>> I'm not sure that there is anyone else around as I haven't had a
>>>>>> response to any of my last three emails but this is where the crash
>>>>>> is
>>>>>> coming from:
>>>>>>
>>>>>> In:
>>>>>>
>>>>>> LUA_API void lua_close (lua_State *L) {
>>>>>>
>>>>>> The line:
>>>>>>
>>>>>> while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
>>>>>>
>>>>>> Which (after drilling all the way down) get to:
>>>>>>
>>>>>> int luaD_precall (lua_State *L, StkId func, int nresults) {
>>>>>>
>>>>>> And then the crash seems to happen around:
>>>>>>
>>>>>> lua_unlock(L);
>>>>>> n = (*curr_func(L)->c.f)(L); /* do the actual call */
>>>>>>
>>>>>> Does this seem familiar to anyone else? Does anyone have any ideas
>>>>>> about this crash and how it relates to laubind?
>>>>>>
>>>>>> If I do not open luabind then the crash does not happen.
>>>>>>
>>>>>> Thanks (if there is anyone out there),
>>>>>>
>>>>>> mark.
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]> wrote:
>>>>>>> Hi Everyone,
>>>>>>>
>>>>>>> I asked this in a separate email, but I thought that it might get
>>>>>>> more
>>>>>>> traction if I ask it by itself.
>>>>>>>
>>>>>>> Does anyone know what the bjam commands would be to compile luabind
>>>>>>> as
>>>>>>> a static library that links against the lua dll?
>>>>>>>
>>>>>>> I'm getting a crashe on lua_close() and it smells like the crashes
>>>>>>> that one gets when there are two instances of the lua runtime being
>>>>>>> used.
>>>>>>>
>>>>>>> I can get my application to crash as long as I call:
>>>>>>>
>>>>>>> luabind::open(pLuaState);
>>>>>>>
>>>>>>> luabind appears to be working, but when the program closes I always
>>>>>>> get a crash, whether I bind to any of my C++ or not (as long as I
>>>>>>> have
>>>>>>> the above call).
>>>>>>>
>>>>>>> I'm using the following in a bat file to compile luabind:
>>>>>>>
>>>>>>> "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
>>>>>>> toolset=msvc-9.0 runtime-link=static link=static threading=multi
>>>>>>> --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>>>>>>>
>>>>>>> Am I crazy? Am I doing something wrong? Any help would be
>>>>>>> appreciated
>>>>>>> as I would like to use luabind but I keep running into road blocks.
>>>>>>>
>>>>>>> mark.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>>
>>>>>> _______________________________________________
>>>>>> luabind-user mailing list
>>>>>> [hidden email]
>>>>>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>>>>>
>>>>> ________________________________
>>>>> Chatta från inkorgen. Se möjligheterna med Hotmail! Klicka här!
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> luabind-user mailing list
>>>>> [hidden email]
>>>>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>>>>>
>>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> luabind-user mailing list
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> luabind-user mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>>
>> ________________________________
>> Ladda ner världens mest använda webbläsare nu. Ta med dig Hotmail i mobilen!
>> ------------------------------------------------------------------------------
>>
>>
>> _______________________________________________
>> luabind-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>>
>>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user


------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Nigel Atkinson-2
In reply to this post by Mark Mruss
I'm not sure exactly what bjam uses, however I can see one difference in
the way you have compiled your dll and the Lua dll.

/MT and /MTd are different, both pull in a multi-threaded CRT dll,
however /MTd pulls in the debug version.  So what happens is you have
two separate runtimes being used, and nasty things happen when for
example, memory is allocated in one, and free'd in the other etc.

Whatever bjam does will have to be the same too.

Hope that's the bug found! :-)

Nigel

On Tue, 2010-05-18 at 11:57 -0500, Mark Mruss wrote:

> Nigel:
>
> This is the commandline that I used when compiling the lua DLL:
>
> /Od /I "../include" /D "_CRT_SECURE_NO_DEPRECATE" /D "DEBUG" /D
> "MSVC9" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1 /MT /Gy
> /Fo"../obj/lua5.1_dll/Debug\\" /Fd"../obj/lua5.1_dll/Debug\vc90.pdb"
> /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt
>
> This is the bjam command that I use to compile luabind:
>
>
> "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
> toolset=msvc-9.0 runtime-link=static link=static threading=multi
> --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>
> And funally this is what I use to compile my dll:
>
> /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_USRDLL" /D "_WINDLL" /D
> "_MBCS" /Gm /EHsc /RTC1 /MTd /Yu"stdafx.h" /Fp"Debug\CVSList.pch"
> /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP
> /errorReport:prompt
>
> Maybe I'm missing something but I think things are compatible?
>
> Kristoffer:
>
> Should I set _SECURE_SCL=1 or just leave it as the default for now?
> I'm not using iterators in my code, but maybe it's something for
> laubind.
>
> Thanks for the answers everyone, hopefully I'll be able to get it
> working. Sorry if I'm missing something obvious.
>
> mark.
>
> On Tue, May 18, 2010 at 3:42 AM, Kristoffer Danielsson
> <[hidden email]> wrote:
> > Beware of _SECURE_SCL=0 setting!
> > http://msdn.microsoft.com/en-us/library/aa985896(VS.80).aspx
> >
> >> From: [hidden email]
> >> To: [hidden email]
> >> Date: Tue, 18 May 2010 07:28:24 +1200
> >> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
> >>
> >> I was about to suggest that your Lua dll and luabind/your program might
> >> be using differing versions of the CRT, but if you have made sure the
> >> compiler settings for each are identical, that is probably not the case.
> >>
> >> You could always try using Lua as a static lib perhaps. Even just to
> >> see if it fixes your bug. It's as easy as dropping most of the Lua
> >> source into your project.
> >>
> >> Nigel
> >>
> >> On Mon, 2010-05-17 at 11:48 -0500, Mark Mruss wrote:
> >> > Hi Kristoffer,
> >> >
> >> > Yes this is a multi-threaded application, in reality there is only one
> >> > main thread and there should only be one instance of the lua runtime.
> >> > (shared dll)
> >> >
> >> > I'm actually using luabind in a dll that will be loaded by my main
> >> > application. I've tried to set all of the compile settings so that the
> >> > luabind.lib matches the compile settings that I used to compile lua,
> >> > but so far all I get are crashes.
> >> >
> >> > I can load lua dll modules without any problems so I think that using
> >> > luabind in a dll should work.
> >> >
> >> > mark.
> >> >
> >> > On Fri, May 14, 2010 at 3:57 PM, Kristoffer Danielsson
> >> > <[hidden email]> wrote:
> >> > > Just guessing here, but is this a multi-threaded application? Really
> >> > > weird
> >> > > crashes might occur if lua is used erroneously in a multithreaded
> >> > > application.
> >> > >
> >> > >> Date: Fri, 14 May 2010 15:54:17 -0500
> >> > >> From: [hidden email]
> >> > >> To: [hidden email]
> >> > >> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on
> >> > >> lua_close_())
> >> > >>
> >> > >> Hi Everyone,
> >> > >>
> >> > >> I'm not sure that there is anyone else around as I haven't had a
> >> > >> response to any of my last three emails but this is where the crash
> >> > >> is
> >> > >> coming from:
> >> > >>
> >> > >> In:
> >> > >>
> >> > >> LUA_API void lua_close (lua_State *L) {
> >> > >>
> >> > >> The line:
> >> > >>
> >> > >> while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
> >> > >>
> >> > >> Which (after drilling all the way down) get to:
> >> > >>
> >> > >> int luaD_precall (lua_State *L, StkId func, int nresults) {
> >> > >>
> >> > >> And then the crash seems to happen around:
> >> > >>
> >> > >> lua_unlock(L);
> >> > >> n = (*curr_func(L)->c.f)(L); /* do the actual call */
> >> > >>
> >> > >> Does this seem familiar to anyone else? Does anyone have any ideas
> >> > >> about this crash and how it relates to laubind?
> >> > >>
> >> > >> If I do not open luabind then the crash does not happen.
> >> > >>
> >> > >> Thanks (if there is anyone out there),
> >> > >>
> >> > >> mark.
> >> > >>
> >> > >>
> >> > >>
> >> > >> On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]> wrote:
> >> > >> > Hi Everyone,
> >> > >> >
> >> > >> > I asked this in a separate email, but I thought that it might get
> >> > >> > more
> >> > >> > traction if I ask it by itself.
> >> > >> >
> >> > >> > Does anyone know what the bjam commands would be to compile luabind
> >> > >> > as
> >> > >> > a static library that links against the lua dll?
> >> > >> >
> >> > >> > I'm getting a crashe on lua_close() and it smells like the crashes
> >> > >> > that one gets when there are two instances of the lua runtime being
> >> > >> > used.
> >> > >> >
> >> > >> > I can get my application to crash as long as I call:
> >> > >> >
> >> > >> > luabind::open(pLuaState);
> >> > >> >
> >> > >> > luabind appears to be working, but when the program closes I always
> >> > >> > get a crash, whether I bind to any of my C++ or not (as long as I
> >> > >> > have
> >> > >> > the above call).
> >> > >> >
> >> > >> > I'm using the following in a bat file to compile luabind:
> >> > >> >
> >> > >> > "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
> >> > >> > toolset=msvc-9.0 runtime-link=static link=static threading=multi
> >> > >> > --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
> >> > >> >
> >> > >> > Am I crazy? Am I doing something wrong? Any help would be
> >> > >> > appreciated
> >> > >> > as I would like to use luabind but I keep running into road blocks.
> >> > >> >
> >> > >> > mark.
> >> > >> >
> >> > >>
> >> > >>
> >> > >>
> >> > >> ------------------------------------------------------------------------------
> >> > >>
> >> > >> _______________________________________________
> >> > >> luabind-user mailing list
> >> > >> [hidden email]
> >> > >> https://lists.sourceforge.net/lists/listinfo/luabind-user
> >> > >
> >> > > ________________________________
> >> > > Chatta från inkorgen. Se möjligheterna med Hotmail! Klicka här!
> >> > >
> >> > > ------------------------------------------------------------------------------
> >> > >
> >> > >
> >> > > _______________________________________________
> >> > > luabind-user mailing list
> >> > > [hidden email]
> >> > > https://lists.sourceforge.net/lists/listinfo/luabind-user
> >> > >
> >> > >
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> >
> >> > _______________________________________________
> >> > luabind-user mailing list
> >> > [hidden email]
> >> > https://lists.sourceforge.net/lists/listinfo/luabind-user
> >>
> >>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> luabind-user mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/luabind-user
> >
> > ________________________________
> > Ladda ner världens mest använda webbläsare nu. Ta med dig Hotmail i mobilen!
> > ------------------------------------------------------------------------------
> >
> >
> > _______________________________________________
> > luabind-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/luabind-user
> >
> >
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Mark Mruss
In reply to this post by Kristoffer Danielsson
Thanks, I'll take a look at this and combine it with the other suggestions.

mark.

On Tue, May 18, 2010 at 12:06 PM, Kristoffer Danielsson
<[hidden email]> wrote:

> Make sure you set _SECURE_SCL=0 in release mode. Otherwise you get a huge
> performance hit on your iterators! In debug-mode you should leave it set to
> _SECURE_SCL=1.
>
> Something like this:
> bjam --toolset=msvc-9.0 --build-type=complete release/define=_SECURE_SCL=0
> debug/define=_SECURE_SCL=1 --stagedir=stage stage
>
>
>> Date: Tue, 18 May 2010 11:57:33 -0500
>> From: [hidden email]
>> To: [hidden email]
>> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on lua_close_())
>>
>> Nigel:
>>
>> This is the commandline that I used when compiling the lua DLL:
>>
>> /Od /I "../include" /D "_CRT_SECURE_NO_DEPRECATE" /D "DEBUG" /D
>> "MSVC9" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1 /MT /Gy
>> /Fo"../obj/lua5.1_dll/Debug\\" /Fd"../obj/lua5.1_dll/Debug\vc90.pdb"
>> /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt
>>
>> This is the bjam command that I use to compile luabind:
>>
>>
>> "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
>> toolset=msvc-9.0 runtime-link=static link=static threading=multi
>> --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>>
>> And funally this is what I use to compile my dll:
>>
>> /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_USRDLL" /D "_WINDLL" /D
>> "_MBCS" /Gm /EHsc /RTC1 /MTd /Yu"stdafx.h" /Fp"Debug\CVSList.pch"
>> /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP
>> /errorReport:prompt
>>
>> Maybe I'm missing something but I think things are compatible?
>>
>> Kristoffer:
>>
>> Should I set _SECURE_SCL=1 or just leave it as the default for now?
>> I'm not using iterators in my code, but maybe it's something for
>> laubind.
>>
>> Thanks for the answers everyone, hopefully I'll be able to get it
>> working. Sorry if I'm missing something obvious.
>>
>> mark.
>>
>> On Tue, May 18, 2010 at 3:42 AM, Kristoffer Danielsson
>> <[hidden email]> wrote:
>> > Beware of _SECURE_SCL=0 setting!
>> > http://msdn.microsoft.com/en-us/library/aa985896(VS.80).aspx
>> >
>> >> From: [hidden email]
>> >> To: [hidden email]
>> >> Date: Tue, 18 May 2010 07:28:24 +1200
>> >> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on
>> >> lua_close_())
>> >>
>> >> I was about to suggest that your Lua dll and luabind/your program might
>> >> be using differing versions of the CRT, but if you have made sure the
>> >> compiler settings for each are identical, that is probably not the
>> >> case.
>> >>
>> >> You could always try using Lua as a static lib perhaps. Even just to
>> >> see if it fixes your bug. It's as easy as dropping most of the Lua
>> >> source into your project.
>> >>
>> >> Nigel
>> >>
>> >> On Mon, 2010-05-17 at 11:48 -0500, Mark Mruss wrote:
>> >> > Hi Kristoffer,
>> >> >
>> >> > Yes this is a multi-threaded application, in reality there is only
>> >> > one
>> >> > main thread and there should only be one instance of the lua runtime.
>> >> > (shared dll)
>> >> >
>> >> > I'm actually using luabind in a dll that will be loaded by my main
>> >> > application. I've tried to set all of the compile settings so that
>> >> > the
>> >> > luabind.lib matches the compile settings that I used to compile lua,
>> >> > but so far all I get are crashes.
>> >> >
>> >> > I can load lua dll modules without any problems so I think that using
>> >> > luabind in a dll should work.
>> >> >
>> >> > mark.
>> >> >
>> >> > On Fri, May 14, 2010 at 3:57 PM, Kristoffer Danielsson
>> >> > <[hidden email]> wrote:
>> >> > > Just guessing here, but is this a multi-threaded application?
>> >> > > Really
>> >> > > weird
>> >> > > crashes might occur if lua is used erroneously in a multithreaded
>> >> > > application.
>> >> > >
>> >> > >> Date: Fri, 14 May 2010 15:54:17 -0500
>> >> > >> From: [hidden email]
>> >> > >> To: [hidden email]
>> >> > >> Subject: Re: [luabind] Static lib and lua5.1.dll (crash on
>> >> > >> lua_close_())
>> >> > >>
>> >> > >> Hi Everyone,
>> >> > >>
>> >> > >> I'm not sure that there is anyone else around as I haven't had a
>> >> > >> response to any of my last three emails but this is where the
>> >> > >> crash
>> >> > >> is
>> >> > >> coming from:
>> >> > >>
>> >> > >> In:
>> >> > >>
>> >> > >> LUA_API void lua_close (lua_State *L) {
>> >> > >>
>> >> > >> The line:
>> >> > >>
>> >> > >> while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
>> >> > >>
>> >> > >> Which (after drilling all the way down) get to:
>> >> > >>
>> >> > >> int luaD_precall (lua_State *L, StkId func, int nresults) {
>> >> > >>
>> >> > >> And then the crash seems to happen around:
>> >> > >>
>> >> > >> lua_unlock(L);
>> >> > >> n = (*curr_func(L)->c.f)(L); /* do the actual call */
>> >> > >>
>> >> > >> Does this seem familiar to anyone else? Does anyone have any ideas
>> >> > >> about this crash and how it relates to laubind?
>> >> > >>
>> >> > >> If I do not open luabind then the crash does not happen.
>> >> > >>
>> >> > >> Thanks (if there is anyone out there),
>> >> > >>
>> >> > >> mark.
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >> On Sun, May 9, 2010 at 7:56 AM, Mark Mruss <[hidden email]>
>> >> > >> wrote:
>> >> > >> > Hi Everyone,
>> >> > >> >
>> >> > >> > I asked this in a separate email, but I thought that it might
>> >> > >> > get
>> >> > >> > more
>> >> > >> > traction if I ask it by itself.
>> >> > >> >
>> >> > >> > Does anyone know what the bjam commands would be to compile
>> >> > >> > luabind
>> >> > >> > as
>> >> > >> > a static library that links against the lua dll?
>> >> > >> >
>> >> > >> > I'm getting a crashe on lua_close() and it smells like the
>> >> > >> > crashes
>> >> > >> > that one gets when there are two instances of the lua runtime
>> >> > >> > being
>> >> > >> > used.
>> >> > >> >
>> >> > >> > I can get my application to crash as long as I call:
>> >> > >> >
>> >> > >> > luabind::open(pLuaState);
>> >> > >> >
>> >> > >> > luabind appears to be working, but when the program closes I
>> >> > >> > always
>> >> > >> > get a crash, whether I bind to any of my C++ or not (as long as
>> >> > >> > I
>> >> > >> > have
>> >> > >> > the above call).
>> >> > >> >
>> >> > >> > I'm using the following in a bat file to compile luabind:
>> >> > >> >
>> >> > >> > "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
>> >> > >> > toolset=msvc-9.0 runtime-link=static link=static threading=multi
>> >> > >> > --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>> >> > >> >
>> >> > >> > Am I crazy? Am I doing something wrong? Any help would be
>> >> > >> > appreciated
>> >> > >> > as I would like to use luabind but I keep running into road
>> >> > >> > blocks.
>> >> > >> >
>> >> > >> > mark.
>> >> > >> >
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >> ------------------------------------------------------------------------------
>> >> > >>
>> >> > >> _______________________________________________
>> >> > >> luabind-user mailing list
>> >> > >> [hidden email]
>> >> > >> https://lists.sourceforge.net/lists/listinfo/luabind-user
>> >> > >
>> >> > > ________________________________
>> >> > > Chatta från inkorgen. Se möjligheterna med Hotmail! Klicka här!
>> >> > >
>> >> > >
>> >> > > ------------------------------------------------------------------------------
>> >> > >
>> >> > >
>> >> > > _______________________________________________
>> >> > > luabind-user mailing list
>> >> > > [hidden email]
>> >> > > https://lists.sourceforge.net/lists/listinfo/luabind-user
>> >> > >
>> >> > >
>> >> >
>> >> >
>> >> >
>> >> > ------------------------------------------------------------------------------
>> >> >
>> >> > _______________________________________________
>> >> > luabind-user mailing list
>> >> > [hidden email]
>> >> > https://lists.sourceforge.net/lists/listinfo/luabind-user
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >>
>> >> _______________________________________________
>> >> luabind-user mailing list
>> >> [hidden email]
>> >> https://lists.sourceforge.net/lists/listinfo/luabind-user
>> >
>> > ________________________________
>> > Ladda ner världens mest använda webbläsare nu. Ta med dig Hotmail i
>> > mobilen!
>> >
>> > ------------------------------------------------------------------------------
>> >
>> >
>> > _______________________________________________
>> > luabind-user mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/luabind-user
>> >
>> >
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> luabind-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
> ________________________________
> Alla mejlkonton på ett ställe. Se möjligheterna med Hotmail! Internet
> Explorer 8
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>

------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Mark Mruss
In reply to this post by Catherine West
Hi Catherine,

This is exactly what I think is happening. I think I'm getting two
"lua runtimes" and because of the static variables I'm getting the
crash. I just haven't been able to figure it out!

I can't move to a static linking of lua because we want out program to
be able to support lua DLL modules which require you to link with the
lua DLL or you will get the exact same lua static variable problem.

As far as I can tell everything should work...I'm just missing something.

Thanks,

mark.

On Tue, May 18, 2010 at 12:30 PM, Catherine West <[hidden email]> wrote:

> This sounds kinda similar to a problem I was having a while ago on OS X that turned out to be caused by duplicate symbols.
>
> I was doing the opposite of what you were doing... lua was built as a static library, and luabind was being built shared.
>
> There seemed to be duplicate per library static variables in the lua library that were included in both my final binary (linked to the static lua library) and luabind (shared library, linked to the static lua library)
>
> The duplicate static variables seemed to be garbage collector related, and normally my app would crash on shutdown, but I could get it to crash earlier by calling collectGarbage() in lua.
>
> I *think* I did my analysis correctly, but I may not fully understand all the rules for the scope of static variables when it comes to the linker on different compilers / OSes.
>
> I second the suggestion to try linking lua statically, as that eliminates the potential for duplicate per shared library symbols.
>
> I hope you can get it figured out!
> -Catherine
>

------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Static lib and lua5.1.dll (crash on lua_close_())

Mark Mruss
In reply to this post by Nigel Atkinson-2
Hi Nigel,

Thanks for that catch. I will have to give this a try when I get home
tonight. Hopefully that is the problem. I will respond with my
results.

Thanks again everyone.

mark.

On Tue, May 18, 2010 at 7:03 PM, Nigel Atkinson <[hidden email]> wrote:

> I'm not sure exactly what bjam uses, however I can see one difference in
> the way you have compiled your dll and the Lua dll.
>
> /MT and /MTd are different, both pull in a multi-threaded CRT dll,
> however /MTd pulls in the debug version.  So what happens is you have
> two separate runtimes being used, and nasty things happen when for
> example, memory is allocated in one, and free'd in the other etc.
>
> Whatever bjam does will have to be the same too.
>
> Hope that's the bug found! :-)
>
> Nigel
>
> On Tue, 2010-05-18 at 11:57 -0500, Mark Mruss wrote:
>> Nigel:
>>
>> This is the commandline that I used when compiling the lua DLL:
>>
>> /Od /I "../include" /D "_CRT_SECURE_NO_DEPRECATE" /D "DEBUG" /D
>> "MSVC9" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1 /MT /Gy
>> /Fo"../obj/lua5.1_dll/Debug\\" /Fd"../obj/lua5.1_dll/Debug\vc90.pdb"
>> /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt
>>
>> This is the bjam command that I use to compile luabind:
>>
>>
>> "C:\Program Files\boost\boost_1_42\bin\bjam.exe" -d+02
>> toolset=msvc-9.0 runtime-link=static link=static threading=multi
>> --debug-build define=LUA_BUILD_AS_DLL define=_MBCS
>>
>> And funally this is what I use to compile my dll:
>>
>> /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_USRDLL" /D "_WINDLL" /D
>> "_MBCS" /Gm /EHsc /RTC1 /MTd /Yu"stdafx.h" /Fp"Debug\CVSList.pch"
>> /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP
>> /errorReport:prompt
>>
>> Maybe I'm missing something but I think things are compatible?
>>
>> Kristoffer:
>>
>> Should I set _SECURE_SCL=1 or just leave it as the default for now?
>> I'm not using iterators in my code, but maybe it's something for
>> laubind.
>>
>> Thanks for the answers everyone, hopefully I'll be able to get it
>> working. Sorry if I'm missing something obvious.
>>
>> mark.
>>

------------------------------------------------------------------------------

_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Cmake file for finding Luabind

Nigel Atkinson-2
Hi All,

I took a copy of the Lua 5.1 cmake file and changed it to find Luabind.
It no doubt could be improved, however it's working find for me on
Linux.  It should in theory work on Win and Mac too.

I thought it might be useful to others, so here it is! :-)

Nigel

------------------------------------------------------------------------------


_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user

FindLuabind.cmake (1K) Download Attachment