-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fann_set_callback segfault of apache/php #33
Comments
To add a bit of insight:
I've added flush() to your test callback, then you can see the issue closer:
You can see it is called a second time as supposed by the positive integer.
|
I've located the issue(s):
This one here causes a segfault. This is the first segfault location. A second one is below: This one also causes a segfault. I've documented both out in my fann.c and it now works properly. |
Hi, thanks for the report but I'm not able to recreate it. It should be actually either For me the fann_set_callback_basic.phpt prints 51 times the info about execution and doesn't segfault if I change return value to Can you provide more info about your platform, PHP version and so on and I will try to recreate once I get more time. |
That's unexpected. I am using your latest version from github. From PHP Info: Kernel: Library: Are you sure the two parts I changed are without any fault ? If you have no segfault it might still be a bug but due to different debugging information or some other compilation differences it's just not "triggered". |
Hi Bukka,
first of all: great job on the binder!
I'm sadly not familiar with PHP extensions so I can't fix this without much effort.
fann_set_callback() is working but the PHP function will cause a segmentation fault when it returns a positive integer.
However, it is required for the callback to return an integer, that's why your test is failing.
https://github.com/bukka/php-fann/blob/master/tests/fann_set_callback_basic.phpt
Your test example for fann_set_callback() is not returning an integer, this causes the training to be interrupted.
That's why you only get one callback and it stops, that's an error in your test script.
Look here please: http://libfann.github.io/fann/docs/files/fann_data-h.html#fann_callback_type
The callback function is supposed to be called during training (each epoch as configured).
Another integer is supposed to keep running.
With PHP however it's not working at all.
When you return 0 it will abort just like a -1 will abort.
when you return a positive number it will cause a segfault (apache process crashes or php cli crashes)
Now later looking at your implementation it's obvious you actually had the right behaviour in mind but forgot testing the second case.
PHP doc should say that return of false means an abort and return of true causes the training to continue.
You can test it in your own example, just "return 1" at the end of the callback and it will segfault.
Tested with libfann 2.2 and your latest extension
The text was updated successfully, but these errors were encountered: