4

How can I debug a segmentation fault when running php script with hhvm? When I run it, I get:

Core dumped: Segmentation fault
Segmentation fault

In stacktrace I get that it error when I call a method of the same object.

Is there any code analyzer that might tell me wrong php code or somehow to get more verbose on errors or stack trace?

When I use

    $r = mysql_query($sql, $link); //crashes
    $r = mysql_query($sql); //does not crash
catalinux
  • 1,462
  • 14
  • 26

1 Answers1

1

Debug build

To get a better understanding of the crash, you need to build HHVM for debug.

This can be done by adding -DCMAKE_BUILD_TYPE=Debug to your cmake.

More info can be found here: https://github.com/facebook/hhvm/wiki/Reporting-Crashes


Stack trace

You may also find a trace named stacktrace.[number].log in the /tmp directory.

If after inspecting the stack trace you realise that the bug is not on your side, it is best to submit a new issue here: https://github.com/facebook/hhvm/issues


Better logging

Once the issue is not a seg fault, you can get more out of your logging.

Here is how my hhvm.hdf log section looks like.

Community
  • 1
  • 1
Sina
  • 607
  • 7
  • 22
  • I did analyze the stack trace. Unfortunately I do not know how to interpret those info & also do not know how can I decide if the bug is on my side. – catalinux Apr 02 '14 at 06:57
  • Can you share the stack trace? Also a snippet of the code would also be helpful. I don't think there is any automated tool that decides whether a bug is on your side or not. If the code seems to be rather trivial and it runs fine on php 5.5, then it is possibly due to a bug in hhvm. – Sina Apr 02 '14 at 07:21
  • For now, i can share stacktrace: http://pastebin.com/UHT6cLFp. I will try to create a code that reproduces the same error – catalinux Apr 02 '14 at 08:38
  • Ok, are you also running the latest version of hhvm? (3.0.1) There was a recent issue with mysqli_fetch_assoc on version 3 (but that wasn't resulting in a seg fault). https://github.com/facebook/hhvm/issues/2218 – Sina Apr 02 '14 at 09:12
  • I am using, HipHop VM 3.0.0-dev (rel). Also, I am using mysql_ and not mysqli_. Actually my problems gets around using $link that is returrned by mysql_connect(). I updated my question – catalinux Apr 02 '14 at 09:29
  • As a heads up, mysql_query is deprecated as of php 5.5. You should use mysqli or PDO. Additionally, the `link` as far as I know is not mandatory (if a link is already established, it will use that). – Sina Apr 02 '14 at 09:33
  • True, is not mandatory, but I use 2 different connection in my code, so I need that. As curiosity, the line that crashes gives "Notice: Array to string conversion in". I'll try to change mysqli – catalinux Apr 02 '14 at 09:35
  • 1
    It is almost impossible to provide any further help without a larger snippet of the code and the reported errors. It might be the case that mysql_query is using a `string` $link, and due to a type mismatch it is crashing. but I am not sure how that can be happening without the rest of the code. – Sina Apr 02 '14 at 09:43
  • I know. I'll work on it and came back with a feedback. Another problem might be that mysqli_query has an reveresed order of parameters. Thank you for all help. – catalinux Apr 02 '14 at 09:46