PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, November 13, 2022

[FIXED] How to understand php errors from dmesg

 November 13, 2022     memcached, php, segmentation-fault     No comments   

Issue

I get a blank page and a new entry in dmesg for every single request.

php[41369] general protection ip:5c0cc3 sp:7fff281f0d98 error:0 in php[400000+33c000]
php[41399] general protection ip:5c0cc3 sp:7fffad17fd68 error:0 in php[400000+33c000]
php[41408] general protection ip:5c0cc3 sp:7fff84481ce8 error:0 in php[400000+33c000]
php[41412] general protection ip:5c0cc3 sp:7fff56af32f8 error:0 in php[400000+33c000]
php[41417] general protection ip:5c0cc3 sp:7fff1e4d1ca8 error:0 in php[400000+33c000]
php[41426] general protection ip:5c0cc3 sp:7fff87a67108 error:0 in php[400000+33c000]
php[41431] general protection ip:5c0cc3 sp:7fffb16bacc8 error:0 in php[400000+33c000]
php[41437] general protection ip:5c0cc3 sp:7fffbc41d5c8 error:0 in php[400000+33c000]

I've already found that it's caused by php-memcache. When switching my caching driver to anything but memcached it seems to work properly (I've tested file and array => no caching). But as I want memcached I am wondering how can I investigate further?


Solution

How to understand php errors from dmesg

It's pretty simple: it tells you that php binary was mapped at address range [0x400000, 0x400000+33c000) (normal for x86_64 binaries on Linux), and that various processes (pid 41369, 41399, etc.) crashed with register rip (aka program counter) set to 0x5c0cc3, and register rsp (aka stack pointer) set to various values (stack is randomized on Linux).

Since all rip values are the same, the crash is happening in the exact same place in all instances.

how can I investigate further?

You need to install debug symbols for this php build.

Once you do, you can first determine which function the crash is happening in, like so:

gdb /path/to/php
(gdb) x/i 0x5c0cc3   # GDB will tell you instruction and function

Once you know the function, you could google for a solution or a known bug.

You could also attach GDB to a running php process, then issue a request. If your php crashes, you will now be able to see the call stack that lead to the crash with (gdb) where command.

Beyond that, you can build the php packages from source, with optimization disabled, and do source debugging.

All of this assumes that you know how to compile packages, how to debug C code, etc. If you don't know that, you'll have to enlist someone who does.



Answered By - Employed Russian
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing