the result of the execution with printf() added in luaopen_xbdm and luaxbdm_gc:
lua LanesBug.wlua
luaopen_xbdm: threadId = 4596
luaopen_xbdm: threadId = 1836
luaxbdm_gc: userdata threadId = 1836, current thread id = 4596
luaxbdm_gc: userdata threadId = 4596, current thread id = 4596
the string issued by luaL_error doesn't reach the lane's join() return values.
Also, maybe not directly related, but bear in mind that if your threads
join an apartment (an STA in your case) then your thread must pump messages.
You might want to try to join the MTA (COINIT_MULTITHREADED)
The fact is, I am using IUP, and it initializes itself with APARTMENTTHREADED. I wouldn't want to get a different initialisation model depending on the order the modules are required. And maybe IUP already takes care of all the necessary pumping :-)