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 |