PHP code generates segmentation error

Edit added.

I get a segmentation error from a triple PHP operation. I am using PHP (5.4.13).

<?php $t = empty($_GET['t2']) ? $_GET['t2'] : 'test'; $t = empty($_GET['t2']) ? 'test' : $_GET['t2']; echo '<pre>'.print_r($t, true).'</pre>'; ?> 

Operators:

 $t = empty($_GET['t2']) ? $_GET['t2'] : 'test'; $t = empty($_GET['t2']) ? 'test' : $_GET['t2']; 

Sends a segmentation error (for this I checked the apache error log). The statements written above do not cause segmentation errors.

I doubt this is the only source error, but this is what I was able to narrow down. Almost all sites using this php now have this problem.

I do not think this is a mistake! More errors when installing php or in one of the dependencies. But since function not used, only language features, I thought that it could be smoothed out quite easily.

EDIT: I wanted to know what common problems cause a segmentation error, and if one of them can be identified from the above code, so that I know where to look for solutions and how to proceed. (this is a question for those who think about it)

EDIT 2: Ready now, no more assignment in $ _GET, so I think now it is advisable and valid. But the error still exists.

EDIT 3: for valgrind trace:

 ==3775== Process terminating with default action of signal 11 (SIGSEGV) ==3775== Bad permissions for mapped region at address 0x0 ==3775== at 0x0: ??? ==3775== by 0xF60F9F7: execute (in /opt/rh/php54/root/usr/lib64/httpd/modules/libphp5.so) ==3775== by 0xF5A619F: zend_execute_scripts (in /opt/rh/php54/root/usr/lib64/httpd/modules/libphp5.so) ==3775== by 0xF548E87: php_execute_script (in /opt/rh/php54/root/usr/lib64/httpd/modules/libphp5.so) ==3775== by 0xF650A94: ??? (in /opt/rh/php54/root/usr/lib64/httpd/modules/libphp5.so) ==3775== by 0x133BAF: ap_run_handler (in /usr/sbin/httpd) ==3775== by 0x13746D: ap_invoke_handler (in /usr/sbin/httpd) ==3775== by 0x142B2F: ap_process_request (in /usr/sbin/httpd) ==3775== by 0x13F9A7: ??? (in /usr/sbin/httpd) ==3775== by 0x13B6B7: ap_run_process_connection (in /usr/sbin/httpd) ==3775== by 0x147976: ??? (in /usr/sbin/httpd) ==3775== by 0x147C45: ??? (in /usr/sbin/httpd) 

and for gdb:

 #0 0x0000000000000000 in ?? () #1 0x00007fc4dd8a49f8 in execute () from /etc/httpd/modules/libphp54-php5.so #2 0x00007fc4dd83b1a0 in zend_execute_scripts () from /etc/httpd/modules/libphp54-php5.so #3 0x00007fc4dd7dde88 in php_execute_script () from /etc/httpd/modules/libphp54-php5.so #4 0x00007fc4dd8e5a95 in ?? () from /etc/httpd/modules/libphp54-php5.so #5 0x00007fc4e818dbb0 in ap_run_handler () #6 0x00007fc4e819146e in ap_invoke_handler () #7 0x00007fc4e819cb30 in ap_process_request () #8 0x00007fc4e81999a8 in ?? () #9 0x00007fc4e81956b8 in ap_run_process_connection () #10 0x00007fc4e81a1977 in ?? () #11 0x00007fc4e81a1c46 in ?? () #12 0x00007fc4e81a2293 in ap_mpm_run () #13 0x00007fc4e8179900 in main () 

Final editing

As I suspected from the very beginning, this, of course, was due to a damaged installation of php and its extensions. The code itself did not cause problems, but I assume that it used part of the failed installation. More can be added, but since I did not find the exact reason and its solution, but managed to get it to work again, I thank you all for making the decision.

+6
source share
1 answer

When looking at your code, I do not think you have any errors.

With that said, you mentioned that you are having problems with many of your sites. I am wondering if you are now getting malicious bots that can cause an error similar to what is in this [PHP Bug Report] [1] https://bugs.php.net/bug.php?id=59748. [1]:.

I would look at your logs and see if the traffic on these sites has changed to start using this problem.

+1
source

Source: https://habr.com/ru/post/944121/


All Articles