[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-server-cvs
Subject: [Server-cvs] engine/core _main.cpp,1.176,1.177
From: dcollins () helixcommunity ! org
Date: 2010-08-13 21:17:55
Message-ID: 201008132117.o7DLHWLZ001084 () mailer ! progressive-comp ! com
[Download RAW message or body]
Update of /cvsroot/server/engine/core
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv17041/server/engine/core
Modified Files:
_main.cpp
Log Message:
Synopsis
========
Fixes PR 266127: Linux 64-bit LSB build link failure due to missing pthread_attr_setstack symbol
Branches: HEAD
Suggested Reviewer: Anyone
Description
===========
Even though pthread_attr_setstack() is documented as a mandatory LSB
3.1 symbol, it is failing to link on x86_64:
.../server/engine/core/_main.cpp:1296: undefined reference to `pthread_attr_setstack'
After some Googling this appears to be an LSB 3.1 bug on all non-32-bit
platforms. It is not clear that they understand the importance of the
bug, however. Without it, your ability to define your own stack is
broken. (The older pthread_attr_setstackaddr/pthread_attr_setstacksize
are an API-Fail and simply do not work right... in this case they
cause an immediate crash.)
This is a critical API which we require to define the stack space for
our threads.
The solution is to avoid the link-time issue by looking up the
pthread_attr_setstack() symbol at runtime using dlsym(). We only do this
for the build configuration known to have this problem (LSB3.1 on x86_64).
We save the symbol address in a static variable for future invocations.
Files Affected
==============
server/engine/core/_main.cpp
Testing Performed
=================
Unit Tests:
- N/A
Integration Tests:
- N/A
Leak Tests:
- N/A
Performance Tests:
- N/A
Platforms Tested: linux-lsb31-x86_64
Build verified: linux-lsb31-x86_64
QA Hints
========
* N/A
Index: _main.cpp
===================================================================
RCS file: /cvsroot/server/engine/core/_main.cpp,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -d -r1.176 -r1.177
--- _main.cpp 10 Aug 2010 20:34:35 -0000 1.176
+++ _main.cpp 13 Aug 2010 21:17:52 -0000 1.177
@@ -1239,6 +1239,29 @@
return 0;
}
+#if defined(_LSB31) && defined(__amd64__)
+// The LSB3.1 SDK on x86_64 has a bug where it fails to link to pthread_attr_setstack
+// even though it's both provided by the system and documented as a mandatory API interface.
+// We avoid the link-time issue by looking up the symbol at runtime using dlsym().
+#define pthread_attr_setstack pthread_attr_setstack_wrapper
+
+int pthread_attr_setstack_wrapper(pthread_attr_t *attr, void *stackaddr, size_t stacksize)
+{
+ static int (*pFunc)(pthread_attr_t*, void*, size_t) = 0;
+ if (!pFunc)
+ {
+ void *handle = dlopen (NULL, RTLD_LAZY);
+ if (handle)
+ {
+ pFunc = (int (*)(pthread_attr_t*, void*, size_t))dlsym(handle, "pthread_attr_setstack");
+ dlclose(handle);
+ }
+ }
+ return (*pFunc)(attr, stackaddr, stacksize);
+
+}
+#endif
+
int*
MakeThread(const char* processname,
SimpleCallback* cb,
_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic