Question

I have a php web application that needs to access a PI-Datasource using an application-library written for windows on dll form to fetch the data. Due to the non-polimorphism of PHP we are using a wrapper written in C#-Dotnet in order to use the polimorphism library.

PHP->Wrapper->Lib->PI-System

The problem: PHP crashes, without leaving a log, on the creation of the com object (almost always on every second request). My thought was that probably something in the existing php code could be wrong that causes this fatal-error and after a lot of debugging and trying I simplified the code to this:

$connection = new Com('Something.SomethingClass');

with the variable $connection not being used NEVER! and still every 2nd time I get php-crash (documented in windows error log with an 1000-Error and an 1001-Information)

>Faulting application name: php-cgi.exe, version: 5.4.11.0, time stamp: 0x511a30ec
>Faulting module name: KERNELBASE.dll, version: 6.1.7601.17932, time stamp: 0x503275ba
>Exception code: 0xc0000005
>Fault offset: 0x0000d3cf
>Faulting process id: 0x14d0
>Faulting application start time: 0x01ce89dd0ae23748
>Faulting application path: C:\Program Files\Zend\ZendServer\bin\php-cgi.exe
>Faulting module path: C:\Windows\system32\KERNELBASE.dll

So i tried to generate even more com objects..

$connArray = array();
for($i = 0; $i < 50 ; $i++){
  Core_System_Log::getInstance()->logWithoutMessageId('Before: ' . $i ,Core_System_Log::DEBUG);
  $connArray[i] = new Com('Something.SomethingClass');
  Core_System_Log::getInstance()->logWithoutMessageId('After: ' . $i, Core_System_Log::DEBUG);
}   

All 50 were generated with no problem, and again every 2nd time i tried i got a php fatal error. I tried to used all 50 of them, and they all read values from the PI-System with no problem.

I tried to unset the variables and call also the gc, call the destructor from C#, check the constructor from C# (which just makes an object of the library and had no exception, the object was normally created and still php crashed) but the problem did not disappear.

So, is there any idea? am i doing something wrong (how can it be wrong when every 2nd time it is properly reading the values)?

Environments Tested:

  • OS:Windows Server 2008 R2 64Bit / Windows 7 Prof SP1 32/64Bit
  • PHP: 5.3.9/ 5.3.14 / 5.3.21 / 5.4.11
  • WS: Apache and IIS (few different versions)

UPDATE: The problem was finally in the C# code. There was a call to GC which did not allow the COM object to be closed/deleted correctly having as a result C# to hang (again with no exception) and "triggering" the php fatal error.

Thanks for the responses.

Was it helpful?

Solution 2

UPDATE: The problem was finally in the C# code. There was a call to GC which did not allow the COM object to be closed/deleted correctly having as a result C# to hang. The object was somewhere kept in Ram and the second time the wrapper was called it just hanged/exited (again with no exception) which "triggered" the php fatal error.

OTHER TIPS

If returns crashed without logging into file it look that in code contains sign @.

Example:

@some_function()

This will call function, but if has any errors it will not showing to you, just skipping. Due to some errors PHP can be stopped.

But, can you try upgrade PHP to 5.5 on Windows server?

If you know in which of lines of code throws an error and want to skip, just put isset()

If isset($somevar) or isset(function()) returns true that means are not errors, but if you don't want to stop a function on errors put isset() on a line of code where errors occurred.

I'm not sure how looks class and function inside PHP->Wrapper->Lib->PI-System code so I can tell fully corrected answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top