lua-users home
lua-l archive

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


Threads are EVIL!

On Thu, Dec 3, 2009 at 04:46, Matt "Matic" Page (Lua) <lua@photon.me.uk> wrote:
Roberto Ierusalimschy wrote:
Consequently, I have changed the "dojump" macro in lvm.c to now be:

   #define dojump(L,pc,i) { (pc) += (i); luai_threadyield(); base =  
L->base; }

/Now, I know that some "dojump" calls are also wrapped inside "Protect"  
and therefore the "base = L->base" is going to be duplicated in those  
cases. Of course, my optimising compiler removes the redundancy./

Guess what - the problem has gone away and Lua is not failing its  
assertions anymore (and my Lua code isn't running off the rails)!!


[...]

Any thoughts or comments??
    
One possible culprit is the resize of stacks in the garbage collector.
In one phase of the garbage gollection, the collector may shrink
some stacks if they seem too big. So, I guess it may happen that the
collector running in one thread shrinks the stack of another thread.
(Of course that never crossed my mind until now..)

-- Roberto

  
Roberto - given the infrequent nature of the issue it would appear that it's a GC inside another thread.
Would you say the fix is sufficient? Or are there other things that cross your mind now?? :-)

(BTW, I removed the bold asterisks from the quoted text above to make the modification clearer!)



--
Regards,
Linker Lin
linker.m.lin@gmail.com