You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Costin Manolache <co...@costin.dnt.ro> on 2000/05/16 08:14:15 UTC

JNI problems on Linux ( aol, apache )

:-)

JNI is not easy... I spent all the day debuging with GDB - it seems
Apache2.0 with JNI is also hanging after a number of  requests...

I tried with Sun 1.2.2 and IBM 1.3 - it seems all the thread are
waiting on a mutex, the hang happens in AttachVM and invokeMethod.
It also seems it is somehow associated with GC - I removed everything
from service() ( just return) and it works, but if I add a new byte[2000]
it will hang after few minutes.

I'll try to go further and/or find a workaround...

Regarding the problems with AOLServer - one thing to check is if it uses
SIGUSR1 - the signal used to be used by pthread library. It's a different
problem anyway.  Do you want to contribute the AOL adapter to tomcat?
If so, can you send the intial code, maybe we can also take a look. I never
used AOLServer, but it shouldn't be that different.

There are few things that seems clear:

- Green threads can't work with Apache, AOL or any pthread based program

- invocation still has some bugs. It seems calling native methods from java
works fine and it's used by many people, calling java from C ( with many
concurent threads and for a long time) seems to have a deadlock. That
happens only under load and after a while, and if we can find the bug
probably other people will also be happy.

Costin









Re: JNI problems on Linux ( aol, apache )

Posted by Vasile GABURICI <ga...@ss.pub.ro>.
	I've fixed the 1st problem: headers not getting through. This was
an extremely nasty bug, because my plugin wasn't setting the protocol.
Actually this was code I've "inherited", but no blame on the original
author here.

	For the fokes at AOL, protocol means what schema means for the
Jakarta people! Even worse, it was always set to NULL, because AOLServer
doesn't support URLs with a prepended schema. So, I wrote my own protocol
grabbing function. And the headers are nicely sent by the Java side.

	Now, the second (and toughest problem): threads hang at random
points inside the JVM. I know for a fact that the hanging points are truly
random because I have added extensive logging in the Tomcat core. I did
this with System.err.println, so it should be synchronous...

	It seems that if a request last a bit too much, it hangs. And when
it hangs, it hangs the entire JVM. I know that AOLServer blocks some
signals on ALL connection threads (those that call the JVM):

    /*
     * Block SIGHUP, SIGPIPE, SIGTERM, and SIGINT. This mask is
     * inherited by all subsequent threads so that only this
     * thread will catch the signals in the sigwait() loop below.
     * Unfortunately this makes it impossible to kill the
     * server with a signal other than SIGKILL until startup
     * is complete.
     */

	And Blackdown 1.2.2-RC4 JVM readme warns about:

* Native code using JNI should NOT modify the signal processing state.
  The VM uses signals and any change to the signal handling may result         
  in VM failures.                                                               
 
	Question: is this the real reason? How does Apache 2.0 or Netscape
solve this? I presume that threads don't hang in the JVM on these two...
Any suggestion will be appreciated.

	Thanks,
	Vasile

	PS: I'm looking into -Xrs (reduce signals).

	Okay, I'll send the code. Now it's on par with other plugins :-)
	But it exposes the problem *much* quicker ;-)

On Mon, 15 May 2000, Costin Manolache wrote:

> :-)
> 
> JNI is not easy... I spent all the day debuging with GDB - it seems
> Apache2.0 with JNI is also hanging after a number of  requests...
> 
> I tried with Sun 1.2.2 and IBM 1.3 - it seems all the thread are
> waiting on a mutex, the hang happens in AttachVM and invokeMethod.
> It also seems it is somehow associated with GC - I removed everything
> from service() ( just return) and it works, but if I add a new byte[2000]
> it will hang after few minutes.
> 
> I'll try to go further and/or find a workaround...
> 
> Regarding the problems with AOLServer - one thing to check is if it uses
> SIGUSR1 - the signal used to be used by pthread library. It's a different
> problem anyway.  Do you want to contribute the AOL adapter to tomcat?
> If so, can you send the intial code, maybe we can also take a look. I never
> used AOLServer, but it shouldn't be that different.
> 
> There are few things that seems clear:
> 
> - Green threads can't work with Apache, AOL or any pthread based program
> 
> - invocation still has some bugs. It seems calling native methods from java
> works fine and it's used by many people, calling java from C ( with many
> concurent threads and for a long time) seems to have a deadlock. That
> happens only under load and after a while, and if we can find the bug
> probably other people will also be happy.
> 
> Costin
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
>