From: SourceForge.net <no...@so...> - 2011-08-22 10:24:31
|
Bugs item #3394253, was opened at 2011-08-19 02:06 Message generated for change (Comment added) made by elias You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105665&aid=3394253&group_id=5665 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Windows Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Peterix (peterix) Assigned to: Nobody/Anonymous (nobody) Summary: TLS-related crash with Windows XP and 2003 Initial Comment: Hello, I'm using Allegro 5 for some very weird things in very weird ways :) Basic design is like this: I have a game I have no sources for, but it uses SDL, I replace SDL with my own library, which then acts as a plugin loader. One of the plugins then uses Allegro to paint a nice isometric view of the game world (as opposed to the game's ASCII codes). On windows, this uses the LoadLibrary call, in turn also loading Allegro. The issue is that XP and 2003 have broken implicit TLS when the library that uses TLS is loaded this way, leading to crashes on the first Allegro call. Some links related to the issue: http://msdn.microsoft.com/en-us/library/ms684175%28v=vs.85%29.aspx http://www.nynaeve.net/?p=187 ---------------------------------------------------------------------- >Comment By: Elias Pschernig (elias) Date: 2011-08-22 10:24 Message: Is there nothing like pthread_once or pthread_key we could use instead? This all seems to be way too complicated for something as trivial as wanting a per-thread variable. ---------------------------------------------------------------------- Comment By: Peterix (peterix) Date: 2011-08-20 18:27 Message: Makes sense, obviously the option can be bad when not used with a library - static linked allegro to a binary won't run DLLMain and won't init TLS. It should be possible to set up the build system differently when needed by setting the already available options. In the current state, building allegro fo my particular use case was impossible without code and build system changes. And that's IMHO wrong :) It would be best to have a nice, verbose description of this, so people can set the build system as needed. Setting defaults for a particular type of build is fine and WAND_DLL_TLS should be OFF by default. Let's just not make the option completely useless. ---------------------------------------------------------------------- Comment By: Matthew Leverton (konforce) Date: 2011-08-20 17:30 Message: See http://www.allegro.cc/forums/thread/607408 for context on why it was disabled. ---------------------------------------------------------------------- Comment By: Peterix (peterix) Date: 2011-08-20 16:29 Message: Ok. I solved the problem, but I had to make some changes to the build system and allegro code. It really didn't want me to use DLL TLS. So, first I fixed the build system - even if I set WANT_DLL_TLS, it turned it off behind my back. In CMakeLists.txt replace: 174 if(WIN32) 175 if(WANT_DLL_TLS AND SHARED) 176 set(ALLEGRO_CFG_DLL_TLS 1) 177 endif(WANT_DLL_TLS AND SHARED) 178 endif(WIN32) 179 180 if(MSVC) 181 # MSVC never needs DLL TLS and it just confuses 182 set(ALLEGRO_CFG_DLL_TLS 0) 183 set(COMPILER_MSVC 1) 184 set(ALLEGRO_MSVC 1) with this: 174 if(WIN32) 175 if(WANT_DLL_TLS) 176 set(ALLEGRO_CFG_DLL_TLS 1) 177 endif(WANT_DLL_TLS) 178 endif(WIN32) 179 180 if(MSVC) 181 set(COMPILER_MSVC 1) 182 set(ALLEGRO_MSVC 1) From tls.c remove: 135 // FIXME: The TLS implementation below only works for dynamic linking 136 // right now - instead of using DllMain we should simply initialize 137 // on first request. 138 #ifdef ALLEGRO_STATICLINK 139 #undef ALLEGRO_CFG_DLL_TLS 140 #endif Then it's possible to build allegro as a set of static libs, where they use explicit TLS and can be linked with a plugin library that works on Windows XP. What was the real problem here? I guess not respecting the options selected by the user. When I select that I want DLL TLS with a STATIC build, I mean it and I don't need the build system or the library to second guess my decision :) ---------------------------------------------------------------------- Comment By: Peterix (peterix) Date: 2011-08-19 02:20 Message: Awesome, I'll try that. ---------------------------------------------------------------------- Comment By: Trent Gamblin (trentg) Date: 2011-08-19 02:15 Message: When building Allegro, there is a cmake flag, WANT_DLL_TLS that forces the use of DllMain and the TlsAlloc and the like functions. You may have to build the library yourself as I believe the prebuilt binaries (at least the MSVC ones, but probably not the older MinGW ones) use implicit TLS. From my quick look at your first link, that should fix this particular problem. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105665&aid=3394253&group_id=5665 |