Thread problem with 5.0.2 -> 5.1

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

Thread problem with 5.0.2 -> 5.1

Brian Hassink

The following (simplified) sequence works under 5.0.2…

 

lua_State* thread = lua_newthread(L);

refKey = luaL_ref(L, LUA_REGISTRYINDEX);

lua_pcall(thread, 0, 0, 0);

lua_getglobal(thread, "main");

lua_pushnumber(thread, id);

lua_resume(thread, 1);

 

…but under 5.1 the call to lua_resume() fails, and lua_tostring(thread, -1) returns an inconsistent numerical value (in the range of 0 through 60).

 

Is there something about this sequence that is no longer valid under 5.1?

 

Thanks,

Brian

 

Reply | Threaded
Open this post in threaded view
|

RE: Thread problem with 5.0.2 -> 5.1

Brian Hassink

Actually, I’ve determined that lua_resume() is not failing but rather my script is aborting after a call is made to lua_yield(thread, 0) from a C-function invoked by the script.

 

Has something changed in the yield behavior for threads?

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Brian Hassink
Sent: Tuesday, April 11, 2006 4:36 PM
To: [hidden email]
Subject: Thread problem with 5.0.2 -> 5.1

 

The following (simplified) sequence works under 5.0.2…

 

lua_State* thread = lua_newthread(L);

refKey = luaL_ref(L, LUA_REGISTRYINDEX);

lua_pcall(thread, 0, 0, 0);

lua_getglobal(thread, "main");

lua_pushnumber(thread, id);

lua_resume(thread, 1);

 

…but under 5.1 the call to lua_resume() fails, and lua_tostring(thread, -1) returns an inconsistent numerical value (in the range of 0 through 60).

 

Is there something about this sequence that is no longer valid under 5.1?

 

Thanks,

Brian

 

Reply | Threaded
Open this post in threaded view
|

RE: Thread problem with 5.0.2 -> 5.1

Brian Hassink
In reply to this post by Brian Hassink

Scratch that.  I see now that the return value of lua_resume() has changed between 5.1 and 5.0.2.

 

My code was interpreting non-zero (i.e. LUA_YIELD) as an error code as per the 5.0.2 documentation.

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Brian Hassink
Sent: Tuesday, April 11, 2006 4:51 PM
To: Lua list
Subject: RE: Thread problem with 5.0.2 -> 5.1

 

Actually, I’ve determined that lua_resume() is not failing but rather my script is aborting after a call is made to lua_yield(thread, 0) from a C-function invoked by the script.

 

Has something changed in the yield behavior for threads?

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Brian Hassink
Sent: Tuesday, April 11, 2006 4:36 PM
To: [hidden email]
Subject: Thread problem with 5.0.2 -> 5.1

 

The following (simplified) sequence works under 5.0.2…

 

lua_State* thread = lua_newthread(L);

refKey = luaL_ref(L, LUA_REGISTRYINDEX);

lua_pcall(thread, 0, 0, 0);

lua_getglobal(thread, "main");

lua_pushnumber(thread, id);

lua_resume(thread, 1);

 

…but under 5.1 the call to lua_resume() fails, and lua_tostring(thread, -1) returns an inconsistent numerical value (in the range of 0 through 60).

 

Is there something about this sequence that is no longer valid under 5.1?

 

Thanks,

Brian