Closed jkarneges closed 10 years ago
So I added shared library support in #27. I can confirm that this assertion fails, but it's quite random for me. Most of the time I will never hit that assertion.
Got it. I don't have bandwidth to dig further at this point. I'll just go ahead and revert the shared lib patch for now.
Okay; I'll dig into it myself when I have time. Sorry about that!
If I think about this a bit further, there should be no difference between shared linking and static linking. @halayli, can you think of any time where this assertion might come true? I'm having trouble debugging on my end with my program...
(e.g. fds not setting O_NONBLOCK?)
In theory there shouldn't be a difference. Most probably the assertion is triggered because of memory corruption or whatnot due to shared lib linking issue.
Any further thoughts on this? I tried building again recently (and on a newer machine) and I'm getting that "recompile with -fPIC" error.
One concern I have about the lack of shared library support is that it may prohibit usage of lthread in shared library ecosystems. For example, if you have shared libraries A and B, and app C, and you want to use coroutines in all of them, calling across library boundaries, then I think a shared lthread library is required right? I assume they can't each individually static link lthread.
If I attempt to link liblthread.a with other code to create a shared library (.so), then I get the following error:
/usr/bin/ld: /usr/local/lib/liblthread.a(lthread.c.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/liblthread.a: could not read symbols: Bad value
I tried recompiling lthread with -fPIC and this was enough to get the shared lib to successfully link with liblthread.a and produce a .so file. Unfortunately, the shared lib misbehaves at runtime. Specifically, I get this assertion:
lthread_sched.c:231: lthread_run: Assertion `lt_write != ((void )0) || lt_read != ((void )0)' failed.
It seems getting this to work as a shared lib requires a bit more thought than blindly adding -fPIC.