|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19775 PHP crashes when trying to access 2d int matrix returned from java
Submitted: 2002-10-05 16:55 UTC Modified: 2003-10-30 21:11 UTC
From: waazup at hotmail dot com Assigned:
Status: Wont fix Package: Java related
PHP Version: 4CVS OS: Windows XP Pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: waazup at hotmail dot com
New email:
PHP Version: OS:


 [2002-10-05 16:55 UTC] waazup at hotmail dot com
I used PHP 4.2.3 zip file for windows.
The GD extension and the Java extension are used and the appropriate paths are set for in Java in the php.ini

PHP is crashing when I try to get the value of a specific point in my 2 dimensional array. The error occurs on the second attempt in the same script to read from the array.

Below I will include the java code used and the php code that calls the java object.

Java Code:
 * Filter class designed to do computations for a php script
 * @author (Peter Kroll) 
 * @version (2002-10-02)

public class Filter

     * Constructor for objects of class Filter
    public Filter()

     * applyFilter
     * @param  
     *      filterMatrix: 2 dimensional array of integers
     *      imageMatrix: 2 dimensional array of integers
     * @return 
     *      newImageMatrix: 2 dimensional array of integers
    public int[][] applyFilter(double [][] filterMatrix, int filterDimension, int [][] imageMatrix, int imageSizeX, int imageSizeY)
        int countX;
        int countY;
        double sum = 0;
        int posX;
        int posY;
        int pixelValue;
        int temp;
        int [][] newImageMatrix = new int[imageSizeX][imageSizeY];
        // Apply filter to image
        for(countX = 0; countX < imageSizeX; countX++)
            for(countY = 0; countY < imageSizeY; countY++)
                sum = 0;
                for(posY = 0; posY < filterDimension; posY++)
                    for(posX = 0; posX < filterDimension; posX++)
                        if(countX - posX < 0 || countY - posY < 0)
                            pixelValue = 0;
                            pixelValue = imageMatrix[countX-posX][countY-posY];
                            sum = sum + imageMatrix[countX-posX][countY-posY] * filterMatrix[filterDimension - 1 - posX][filterDimension - 1 - posY];
                newImageMatrix[countX][countY] = (int) sum;
	   return newImageMatrix;

PHP code:
// Apply filter to image
$FilterObject = new Java("Filter");
$newImageMatrix = $FilterObject->applyFilter($filter, $filterDimension, $imageMatrix, $imageSizeX, $imageSizeY);
$tempVal = $newImageMatrix[0][0];
print $tempVal . "<BR>\n";
$tempVal = $newImageMatrix[1][1];
print $tempVal . "<BR>\n";

The PHP code above is not my whole script but the part that calls Java and causes the error.
Please note that the Java compiles fine and there are no errors in the PHP.
The variables passed into the Java method are the same type as required by the Java method.
I am able to read one value from the returned matrix and print it to the screen on the second attempt php crashes, this bug is reproducable 100% of the time.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-21 08:20 UTC]
The Java stuff in PHP is totally unmaintained (and still experimental too). Maybe in PHP 5 it will actually work.

 [2003-10-30 21:11 UTC]
Won't be fixed in PHP 4. 

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jun 12 19:01:24 2021 UTC