lua-users home
lua-l archive

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


Here's an analysis of LoadLibrary behavior in Windows builds of Lua:
http://lua-users.org/wiki/LoadLibrary .  I've come to some possible
conclusions on how Windows builds such as LfW should be changed:

  (A) Lua binary modules should have a unique DLL naming convention,
like "foo.luad" or "foo-lua.dll" rather than "foo.dll", to avoid
conflict with non-Lua DLLs. LUA_CPATH can be updated accordingly.

  (B) Something maybe should be done about Lua 5.2.0-beta
LoadLibraryEx triggering undefined behavior [1] with
LUA_LLE_FLAGS=LOAD_WITH_ALTERED_SEARCH_PATH and relative paths like
package.cpath=".\\?.dll". A recommended approach is to make paths
absolute. This may be done via GetFullPathName, though it possibly
leads to corruption in multithreaded and shared library situations [2]
(why shared libraries???).  Alternately, ".\\?.dll" could could be
removed from package.cpath, but the user might still try to add it.

[1] http://msdn.microsoft.com/en-us/library/windows/desktop/ms684179.aspx
[2] http://msdn.microsoft.com/en-us/library/windows/desktop/aa364963.aspx