From: Alan P. <api...@ma...> - 2005-11-23 07:41:01
|
Hello- I've gotten things working, but sometimes the bridge seems to die mid- request. The server doesn't have a chance to answer, and no data is returned. I've narrowed it down to the iterator interface over returned Java arrays. Here's the offending code: $facets = $facetGenerator->getList($this->value, $this->maxRows, $this->sortByFrequency, $this->maxHits); foreach ($facets as $facet) { // does nothing, but still crashes } getList() returns an array of java objects: public AttributeValue[] getList(java.lang.String attribute_id, int maxRows, boolean sortByFrequency, int maxHits) throws java.io.IOException, NotFoundException Here's a tcpflow dump of the bridge comm for that request: 127.000.000.001.56795-127.000.000.001.09267: . 127.000.000.001.56795-127.000.000.001.09267: <I v="0" m="setJarLibraryPath" p="I" i="45082768"><S v="/Applications/ dieselpoint-search/lib/diesel-3.5.1.jar;/Applications/dieselpoint- search/lib/javax.servlet.jar"/><S v="/"/></I> 127.000.000.001.09267-127.000.000.001.56795: <O v="" i="45082768"/> 127.000.000.001.56795-127.000.000.001.09267: <C v="com.dieselpoint.search.Index" p="C" i="45083920"></C> 127.000.000.001.09267-127.000.000.001.56795: <O v="1" i="45083920"/> 127.000.000.001.56795-127.000.000.001.09267: <I v="1" m="getInstance" p="I" i="45077952"><S v="/Applications/dieselpoint-search/indexes/ showcase"/></I> 127.000.000.001.09267-127.000.000.001.56795: <O v="2" i="45077952"/> 127.000.000.001.56795-127.000.000.001.09267: <U v="1"/><I v="2" m="getItemCount" p="I" i="45075760"></I> 127.000.000.001.09267-127.000.000.001.56795: <L v="0" i="45075760"/> 127.000.000.001.56795-127.000.000.001.09267: <C v="com.dieselpoint.search.FacetGenerator" p="I" i="45004032"><O v="2"/ ></C> 127.000.000.001.09267-127.000.000.001.56795: <O v="3" i="45004032"/> 127.000.000.001.56795-127.000.000.001.09267: <I v="3" m="setRangeCount" p="I" i="46194528"><S v="6"/></I> 127.000.000.001.09267-127.000.000.001.56795: <O v="" i="46194528"/> 127.000.000.001.56795-127.000.000.001.09267: <I v="3" m="getList" p="I" i="46202032"><S v="price"/><L v="-1"/><B v="T"/><L v="1000000"/ ></I> 127.000.000.001.09267-127.000.000.001.56795: <O v="4" i="46202032"/> 127.000.000.001.56795-127.000.000.001.09267: <I v="0" m="getPhpMap" p="I" i="46203008"><O v="4"/></I> 127.000.000.001.09267-127.000.000.001.56795: <O v="5" i="46203008"/> 127.000.000.001.56795-127.000.000.001.09267: <I v="5" m="getType" p="I" i="46203008"></I> 127.000.000.001.09267-127.000.000.001.56795: <B v="F" i="46203008"/> 127.000.000.001.56795-127.000.000.001.09267: <I v="5" m="hasMore" p="I" i="46203008"></I> 127.000.000.001.09267-127.000.000.001.56795: <B v="F" i="46203008"/> 127.000.000.001.56795-127.000.000.001.09267: <I v="5" m="currentKey" p="I" i="46194528"></I> 127.000.000.001.09267-127.000.000.001.56795: <O v="" i="46194528"/> So it seems to me it's somehow getting killed during the iterator. Now, it doesn't ALWAYS fail. Sometimes it works. I think maybe only when EMPTY lists are returned it fails, but I am not positive. Maybe that will help you? Thanks in advance for any thoughts. Please respond to me as well directly as I am not currently on the mailing list. Thanks, Alan |
From: Jost B. <jos...@ya...> - 2005-11-23 18:53:17
|
Hi Alan, > I've gotten things working, but sometimes the bridge > seems to die mid-request. Which component dies, the java.so or the java backend? We know that there are issues with Apple's jdk1.4, which cannot run our bench.php for more than one hour. But this is a known issue with the apple JVM, the crash is reproduceable using a pure java test. (It seems to be a combination of the class gc and the apple JIT). Which JVM do you use? Can you please open a ticket for this and attach the java trace log at the end of the ticket? Regards, Jost Boekemeier ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |
From: Alan P. <api...@ma...> - 2005-11-23 19:05:57
|
I am not sure which component dies. There are no messages left in any log files (apache's error_log, /var/run/php-java-bridge.log, etc). I have posted the bug, and added some more notes from research today. http://sourceforge.net/tracker/index.php? func=detail&aid=1364916&group_id=117793&atid=679233 Thanks, Alan On Nov 23, 2005, at 1:52 PM, Jost Boekemeier wrote: > Hi Alan, > >> I've gotten things working, but sometimes the bridge >> seems to die mid-request. > > Which component dies, the java.so or the java backend? > > We know that there are issues with Apple's jdk1.4, > which cannot run our bench.php for more than one hour. > But this is a known issue with the apple JVM, the > crash is reproduceable using a pure java test. (It > seems to be a combination of the class gc and the > apple JIT). Which JVM do you use? > > Can you please open a ticket for this and attach the > java trace log at the end of the ticket? > > > Regards, > Jost Boekemeier > > > > > > > > ___________________________________________________________ > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier > anmelden: http://mail.yahoo.de |
From: Jost B. <jos...@ya...> - 2005-11-27 23:06:30
|
Hi Alan, problem confirmed. php > 5.0.3 simply crashes when you pass an empty list. > --> <I m="hasMore" p="I" i="46203008"></I> > <-- <B v="F" i="46203008"/> > --> <I v="5" m="currentKey" p="I" i="46194528"></I> it seems that since version 5.0.5 the zend interator advances one element too far when the list is empty. According to your log you have passed an empty list. The zend iterator asks us "hasMore", we return false. After that it asks for the current key(!?!) which doesn't exist, of course, we have returned false! What follows is that php becomes confused and crashes: The currentKey() that java returns isn't valid and php tries to examine the key len, which may or may not result in a segmentation fault and a php crash. I will check the details tomorrow evening, in the meantime please use the following workaround: $php_array = java_values($javaList); // now you can iterate over php_array which checks for // the above invalid condition. Or please downgrade to php 5.0.3 or below. :(( Regards, Jost Boekemeier P.S.: My plan was to drop PHP4 support in PHP/Java Bridge Version 3.0. I don't think this is possible considering that every new php 5 release introduces new bugs. (Since php 5.1 even the serialization doesn't work anymore, which worked in the php5.1 pre betas)... ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |
From: Alan P. <api...@ma...> - 2005-11-27 23:21:44
|
Thanks for the note. However, I am still a bit confused... I can confirm that switch from: foreach ($javaResultList as $i) to foreach (java_values($javaResultList) as $i) Does indeed avoid the bug. BTW I am on PHP 5.0.4... However, if the zend iterator interface is broken on empty lists, then converting the list from JAVA to PHP array shouldn't fix the problem, but it does... The difference is that if it's a java object, it's calling the zend_iterator from the bridge, otherwise calling the internal zend iterator. In both cases the list is empty and thus *should* crash if the zend iterators are externally calling "currentKey" on empty arrays. I certainly agree that it's nonsense for "currentKey" to get called on the iterator when hasMore returns false. Now I know that the Iterator interface hierarchy is big, so maybe the iterator type used on the PHP array is different from the one used / implemented by the bridge? It just seems that if the bug is that empty arrays cause crashes, then the bug shouldn't go away by converting the list to a PHP array. Maybe that you've "mixed" the hashmap and array iterators into a single one is screwing it up? I don't know too much about the zend iterator internals, just trying to make sense of the bug. See what I mean? Alan On Nov 27, 2005, at 6:06 PM, Jost Boekemeier wrote: > Hi Alan, > > problem confirmed. php > 5.0.3 simply crashes when you > pass an empty list. > > >> --> <I m="hasMore" p="I" i="46203008"></I> >> <-- <B v="F" i="46203008"/> >> --> <I v="5" m="currentKey" p="I" i="46194528"></I> > > > it seems that since version 5.0.5 the zend interator > advances one element too far when the list is empty. > According to your log you have passed an empty list. > The zend iterator asks us "hasMore", we return false. > After that it asks for the current key(!?!) which > doesn't exist, of course, we have returned false! > > What follows is that php becomes confused and crashes: > The currentKey() that java returns isn't valid and php > tries to examine the key len, which may or may not > result in a segmentation fault and a php crash. > > I will check the details tomorrow evening, in the > meantime please use the following workaround: > > $php_array = java_values($javaList); > // now you can iterate over php_array which checks for > > // the above invalid condition. > > Or please downgrade to php 5.0.3 or below. :(( > > > Regards, > Jost Boekemeier > > P.S.: My plan was to drop PHP4 support in PHP/Java > Bridge Version 3.0. I don't think this is possible > considering that every new php 5 release introduces > new bugs. (Since php 5.1 even the serialization > doesn't work anymore, which worked in the php5.1 pre > betas)... > > > > > > > > > ___________________________________________________________ > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier > anmelden: http://mail.yahoo.de |
From: Jost B. <jos...@ya...> - 2005-11-28 18:05:11
|
Hi Alan, I should have looked at this more carefully. This is indeed a bug in the PHP/Java Bridge code: when the list is empty, we may pass an uninitialized object to php. After that php may or may not crash, depending on the malloc() strategy and on the iterator implementation. I will prepare version 2.0.9 next week, which fixes this bug. In the meantime please add the following two lines to the get_iterator() in java.c: @@ -1237,6 +1237,8 @@ (*jenv)->writeInvokeEnd(jenv); if(Z_BVAL_P(presult)) init_current_data(iterator TSRMLS_CC); + else + iterator->current_object = NULL; zval_ptr_dtor((zval**)&presult); Thank you very much for this bug report! Regards, Jost Boekemeier ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |