We have a Java server (Linux 64 bit) application that uses native code for its processing stuff. The native code also handles all multithreading issues and has been recently enhanced with fiber switching using boost::context
.
The problem we're facing right now is that AttachCurrentThread
fails for fiber-switched threads. After some long debugging and testing sessions we found the cause for this: the JVM seems to refuse threads with different stack pointers than given on its creation.
We verified this by simply attaching to the JVM from a pthread with modified (but valid) rsp
which fails when rsp
gets modified.
A possible fix would introduce some kind of event handling mechanism to decouple the callbacks from the fiber-switched threads, but I would really like to avoid that.
Does anybody know a workaround for this?
Is it possible to disable the stack checks (Oracle Java 1.7.0_40, 64 bit)?
Can we modify the native pthreads to point to the correct stack frames (I doubt we can)? (We can not set the stack frames in advance).