php-fann
php-fann copied to clipboard
Doublefann not working on windows
Hi, I'm using XAMPP 3.1.0 (PHP5.4.7) on Windows8
Running the sample_training gives me the following crash:

There is no information in the error.log.
I've tried the 1.0.3/1.0.4/1.0.5 versions for 5.4-ts-vc9-x86.zip and they all crash.
Any solution?
I'm not sure about XAMPP 3.1.0, is there such version? On their site http://www.apachefriends.org/de/xampp-windows.html the highest is 1.8.x. Nevertheless, do you have the same crash running that code on CLI? It would be great if you could
- extract a short PHP snippet reproducing this crash
- use this page https://bugs.php.net/bugs-generating-backtrace-win32.php to produce a backtrace
Please try on CLI with the official PHP build first (if you aren't using it already).
Yes, it crashes on cli too.
if (($this->ann = fann_create_from_file($path)) == false) {
throw new \Exception('Could not create ANN from file!');
}
PS. using xampp 1.8.1
Thanks, having the snippet is great. However I'd really appreciate to see the backtrace you have, preferably using the binary from http://windows.php.net/downloads/releases/ .
Thanks
Or xmpp backtrace at least. You can run httpd.exe -X and attach debugger.
Hi, I just tested the snippet with the uploaded file on Linux and it loads the network correctly without any crash. It looks that it is a platform specific though. If you could provide the backtrace, that would be great!
Thanks
I tried but I don't know how to configure the Debug Diagnostics Tool v2.0 (different than 1.2 tutorial). I think I'll first install the latest xampp version, then try again. Then I'll figure this debugging out if it still fails.
Installed xampp 1.8.3 (php5.5.3) but the error still occurs.
Or xmpp backtrace at least. You can run httpd.exe -X and attach debugger.
I don't know how to do this exactly... Is there an easy way to do the debugging? I'm using symfony2.
Is this correct?
Loading control script C:\Program Files\DebugDiag\Scripts\CrashRule_Process_php.exe.vbs
DumpPath set to C:\Program Files\DebugDiag\Logs\Crash rule for all instances of php.exe
[2013-11-01 04:33:03 PM] Process created. BaseModule - c:\xampp\php\php.exe. BaseThread System ID - System ID: 652
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\ntdll.dll loaded at 0x76f70000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\KERNEL32.DLL loaded at 0x751a0000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\KERNELBASE.dll loaded at 0x763a0000
[2013-11-01 04:33:03 PM] C:\Windows\system32\apphelp.dll loaded at 0x744f0000
[2013-11-01 04:33:03 PM] c:\xampp\php\php5ts.dll loaded at 0x72cd0000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\WS2_32.dll loaded at 0x768b0000
[2013-11-01 04:33:03 PM] c:\xampp\php\MSVCR110.dll loaded at 0x73740000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\ADVAPI32.dll loaded at 0x74ab0000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\ODBC32.dll loaded at 0x73820000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\ole32.dll loaded at 0x74830000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\USER32.dll loaded at 0x75080000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\DNSAPI.dll loaded at 0x6f550000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\RPCRT4.dll loaded at 0x764d0000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\NSI.dll loaded at 0x74ec0000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\msvcrt.dll loaded at 0x74c30000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\sechost.dll loaded at 0x74b60000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\combase.dll loaded at 0x746f0000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\GDI32.dll loaded at 0x74950000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\SspiCli.dll loaded at 0x74610000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\CRYPTBASE.dll loaded at 0x74600000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\bcryptPrimitives.dll loaded at 0x745a0000
[2013-11-01 04:33:03 PM] C:\Windows\system32\IMM32.DLL loaded at 0x76e80000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\MSCTF.dll loaded at 0x765a0000
[2013-11-01 04:33:03 PM] C:\ansicon\ANSI32.dll loaded at 0x00a40000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_xdebug.dll loaded at 0x73710000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_bz2.dll loaded at 0x736f0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_curl.dll loaded at 0x72c50000
[2013-11-01 04:33:03 PM] c:\xampp\php\LIBEAY32.dll loaded at 0x67520000
[2013-11-01 04:33:03 PM] c:\xampp\php\SSLEAY32.dll loaded at 0x68db0000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\WLDAP32.dll loaded at 0x76680000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\Normaliz.dll loaded at 0x746e0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_mbstring.dll loaded at 0x72b10000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_exif.dll loaded at 0x73be0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_gd2.dll loaded at 0x729c0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_gettext.dll loaded at 0x736e0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_mysql.dll loaded at 0x736d0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_mysqli.dll loaded at 0x73610000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_openssl.dll loaded at 0x73400000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_pdo_mysql.dll loaded at 0x736c0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_pdo_sqlite.dll loaded at 0x72950000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_soap.dll loaded at 0x733a0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_sockets.dll loaded at 0x72930000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\IPHLPAPI.DLL loaded at 0x6f5d0000
[2013-11-01 04:33:03 PM] C:\Windows\SYSTEM32\WINNSI.DLL loaded at 0x732e0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_sqlite3.dll loaded at 0x728a0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_xmlrpc.dll loaded at 0x72890000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_xsl.dll loaded at 0x6f7c0000
[2013-11-01 04:33:03 PM] C:\xampp\php\ext\php_fann.dll loaded at 0x6f8c0000
[2013-11-01 04:33:03 PM] c:\xampp\php\fanndouble.dll loaded at 0x6b110000
[2013-11-01 04:33:03 PM] Thread created. New thread system id - System ID: 5388
[2013-11-01 04:33:03 PM] Initializing control script
[2013-11-01 04:33:03 PM] Clearing any existing breakpoints
[2013-11-01 04:33:03 PM]
[2013-11-01 04:33:03 PM] Current Breakpoint List(BL)
[2013-11-01 04:33:06 PM] Thread exited. Exiting thread system id - System ID: 5388. Exit code - 0x00000000
[2013-11-01 04:33:06 PM] First chance exception - 0XC0000005 caused by thread with System ID: 652. DetailID = 1
[2013-11-01 04:33:17 PM] Second chance exception - 0XC0000005 caused by thread with System ID: 652
[2013-11-01 04:33:17 PM] Process exited. Exit code - 0xffffffff
***********************
* EXCEPTION DETAILS *
***********************
DetailID = 1
Count: 1
Exception #: 0XC0000005
Stack:
WARNING: Stack unwind information not available. Following frames may be wrong.
fanndouble!fann_get_errno
php_fann!zif_fann_create_from_file
php_xdebug
***********************
* EXCEPTION SUMMARY *
***********************
|--------------------|
| Count | Exception |
|--------------------|
| 1 | 0XC0000005 |
|--------------------|
Report for php__PID__7832__Date__11_01_2013__Time_06_30_02PM__401__Second_Chance_Exception_C0000005.dmp
Type of Analysis Performed Combined Crash/Hang Analysis
Machine Name POWERHOUSE
Operating System Windows 8
Number Of Processors 4
Process ID 7832
Process Image c:\xampp\php\php.exe
System Up-Time 2 day(s) 24:47:36
Process Up-Time 00:00:16
Processor Type X86
Process Bitness 32-Bit
Top 5 Threads by CPU time
Note - Times include both user mode and kernel mode for each thread
Thread ID: 0 Total CPU Time: 00:00:00.545 Entry Point for Thread: php!sapi_cli_single_write+8535
Thread report
Thread 0 - System ID 2564
Entry point php!sapi_cli_single_write+8535
Create time Fri 1 Nov 18:29:52
Time spent in user mode 0 Days 00:00:00.280
Time spent in kernel mode 0 Days 00:00:00.265
This thread is not fully resolved and may or may not be a problem. Further analysis of these threads may be required.
Function
doublefann!fann_get_quickprop_mu+38bc
php_fann!get_module+7551
php5ts!execute_internal+37
php_xdebug!get_module+2378
php5ts!libiconv_open+ad80e
Back to Top
Exception Information
DOUBLEFANN!FANN_GET_QUICKPROP_MU+38BCWARNING - DebugDiag was not able to locate debug symbols for \doublefann.dll, so the information below may be incomplete.
In php__PID__7832__Date__11_01_2013__Time_06_30_02PM__401__Second_Chance_Exception_C0000005.dmp the assembly instruction at doublefann!fann_get_quickprop_mu+38bc in c:\xampp\php\doublefann.dll has caused an access violation exception (0xC0000005) when trying to read from memory location 0x00000000 on thread 0
Module Information
Image Name: c:\xampp\php\doublefann.dll Symbol Type: Export
Base address: 0x00905a4d Time Stamp: Mon Sep 16 14:17:54 2013
Checksum: 0x00000000 Comments:
COM DLL: False Company Name:
ISAPIExtension: False File Description:
ISAPIFilter: False File Version:
Managed DLL: False Internal Name:
VB DLL: False Legal Copyright:
Loaded Image Name: doublefann.dll Legal Trademarks:
Mapped Image Name: Original filename:
Module name: doublefann Private Build:
Single Threaded: False Product Name:
Module Size: 96 KBytes Product Version:
Symbol File Name: doublefann.dll Special Build: &
From what i see now - please exclude xdebug and try again. An example of good usable backtrace is on that page btw https://bugs.php.net/bugs-generating-backtrace-win32.php , just in the first section. The debug symbols should be used. No symfony please, just the repro snippet from above. WinDbg shouldn't differ very much.
Another thing - the XMPP page states you need VC9 for its packages. If they have 5.5 bins compiled with VC9, that will sure conflict with the FANN builds wich are done with VC11 for PHP 5.5. What is the exact constellation they deliver in that package, which compiler is used for Apache and PHP?
@bukka I've just debugged this case. Please look here https://gist.github.com/weltling/7273037 for the diff. What happens is, that fann_create_from_file() delivers NULL. fann_get_errno() will try to dereference it.
The gist fixes that the latter, you might want to modify it for more meaningful reaction. Where I have no idea is why NULL is delivered. That's anyway an existing file and the the libfann refuses it for some reason. Maybe incorrect file format?
The xampp 1.8.3 / php5.5.5 is VC11
I managed to re-create the bug when I tested completely invalid conf file (the uploaded file is correct on linux so I tested completely invalid input: https://github.com/bukka/php-fann/blob/master/tests/fann_create_from_file_basic.phpt#L17
I added the extra checks for empty ann ( https://github.com/bukka/php-fann/commit/4400a4cb8b8686ed55434439ddf39de10adf728f ) but then I got another segfault. It looks that there is some problem in libfann as they are some memory corruptions. Valgrind also showed me quite a few additional problems (memory leaks) for error cases. I will need to do a proper testing and try to sort it out in ext code (in the worst case I will have to rewrite config file parser)...
@weltling Thanks a lot for debugging the code! I have got one question regarding your diff? Did it actually work? As I wrote there is still segfault on my Linux build so I am a bit curios if it works on another build...
@Tjorriemorrie Thanks for reporting the problem. I will release a new version when I fix it... ;)
@bukka, i've actually worked on the snippet and data brought earlier by @Tjorriemorrie. For that the diff i've posted was sufficient. Maybe the data isn't completely invalid, so quite an edge case. Nevertheless libfann delivered NULL.
Please just ping when you think it's ready, i'll trigger a snap from master then.
Cheers