Skip to content
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

[BUG] Segfault in phalcon.so when using Phalcon\Forms\Element::getUserOption(). #1343

Closed
temuri416 opened this issue Oct 7, 2013 · 19 comments

Comments

@temuri416
Copy link
Contributor

I am getting the following error in my syslog:

kernel: [ 8652.459743] php-fpm[5902]: segfault at 2d0150790 ip 00007f0fc61cc147 sp 00007ffffa32a680 error 4 in phalcon.so[7f0fc6185000+2a1000]

The line of code that's causing it:

/**
 * @var Phalcon\Forms\Element
 */
$element->getUserOption('myOption');

I realise that it is of very little use. So, what can I do to provide with more information?

I am on Phalcon 1.3.0.

Thanks!

@Cinderella-Man
Copy link
Contributor

Hi,
Are you using Phalcon\Forms\Element class directly?
I would like to point that this is an abstract class, so you cannot have an instantiate of it.

@temuri416
Copy link
Contributor Author

No, I am not.

$element is an instance of Text, Select or whatever else.

What kind of debug info might be helpful?

@ghost
Copy link

ghost commented Oct 8, 2013

@temuri416 Any chance you can write a simple test case that reproduces the problem?

@temuri416
Copy link
Contributor Author

@sjinks

I'm on it.

@temuri416
Copy link
Contributor Author

Unfortunately, small test I wrote did not crash..

But in my much more complex application environment it is crashing consistently. Instead, I'm using ->getUserOptions(), that works fine.

Any other suggestion?

@ghost
Copy link

ghost commented Oct 8, 2013

If you run

php your-complex-app.php

does it crash?

@temuri416
Copy link
Contributor Author

no, my unit tests pass OK from CLI. It only fails via HTTP.

@ghost
Copy link

ghost commented Oct 8, 2013

OK, what version of PHP do you use?

And what git revision of Phalcon do you use (if you remember)?

@temuri416
Copy link
Contributor Author

I'm on PHP 5.5.0, the same happens with 5.5.1.

I'm on latest Phalcon 1.3.0.

@ghost
Copy link

ghost commented Oct 8, 2013

OK, could you please do this:

  1. Enable core dumps: ulimit -c unlimited
  2. If you are running Ubuntu, please disable apport: sudo service apport stop
  3. Run php as a server: php -S 127.0.0.1:9900 (please do that from the document root)
  4. Try to crash the app from the browser (use http://127.0.0.1:9900/ as the server).

If the app crashes, you will see a file named core. You will need gdb to get the backtrace (sudo apt-get install gdb or similar)

Then run: gdb /path/to/php /path/to/core

At the gdb prompt please run bt and copy and paste the output somewhere. Use quit to quit gdb.

@temuri416
Copy link
Contributor Author

Well... It does not crash when I go to http://127.0.0.1:9900 with Lynx (I don't have any GUI). The same crashes in the browser (goes through nginx/php-fpm).

I'm on Win7, with Ubuntu 13 running in VirtualBox.

@ghost
Copy link

ghost commented Oct 8, 2013

OK, and if you run php -S 0.0.0.0:9900 and try to access your VM from Win7?

@temuri416
Copy link
Contributor Author

Hold on - with 127.0.0.1:9900 in one window I did see this:

[Tue Oct  1 16:53:08 2013] 127.0.0.1:60160 [200]: /
Segmentation fault (core dumped)

Lynx in my other window still loaded the form, and I didn't bother checking window with php -S.

Let me get all that stuff.

@temuri416
Copy link
Contributor Author

Here it comes:

gdb /var/web/php/bin/php ./core

GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /var/web/php/bin/php...done.
[New LWP 27825]

warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fff861b9000
Core was generated by `php -S 127.0.0.1:9900'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f1e6606f147 in phalcon_memory_restore_stack_common.isra.14.constprop.355 () from /var/web/php/lib/php/extensions/no-debug-non-zts-20121212/phalcon.so
(gdb) quit

@ghost
Copy link

ghost commented Oct 8, 2013

Could you please rebuild Phalcon with debug info and try again? This will give a more useful backtrace.

cd ext
phpize --clean
phpize
./configure CFLAGS="-g3 -O0"
make -j2
sudo make install

@ghost
Copy link

ghost commented Oct 8, 2013

Never mind, I have just found the bug

@temuri416
Copy link
Contributor Author

Ohhh gooood :-) Looks like it was well-hidden!

Thank you for your time.

@phalcon
Copy link
Collaborator

phalcon commented Oct 8, 2013

Fixed in 1.3.0 by @sjinks

@phalcon phalcon closed this as completed Oct 8, 2013
@temuri416
Copy link
Contributor Author

Confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants