Skip to main content

PHP weird Seg-faults on mysqli_stmt_bind_result


When migrating a PHP script from PHP 5.2 to PHP 5.3, I've stumbled to the following problem: The general purpose of the script is data mining. I have a procedure inside that adds data to the MySQL server. Since it is really repetitive, I've rewritten it (a while ago) to use MySQLi, in particular prepared statements, since there are a total of 3 possible queries to perform. Anyway, now, on the PHP 5.3 server, the script is crashing on the following line:




mysqli_stmt_bind_result($prepCheck, $id1);



Where $prepCheck is created with $prepCheck = mysqli_prepare($con, $checkQuery) or die("Error"); . The query runs fine on the MySQL server ($checkQuery, that is) and the PHP code was working, too, on the previous server.



Running the script with strace didn't reveal anything, since the last thing in it is the system call for echo "Execute"; , which is 29936 19:44:18 write(1, "Execute\n", 8) = 8 .



The connection object is not FALSE , and even if it was, it should fail with another error, right?



Here comes the weirdest part: This procedure does not fail when I run the script, limiting the number of pages visited and the script completes successfully. However, when I set a higher limit, it fails, always on the first call to this procedure, and precisely on this line.



If anyone has any suggestions what could be causing this, they would be deeply appreciated.



I can paste code if anyone needs to see a larger picture, but the procedure is very long and boring to death (may be that's why the script is failing :).



Here is how the script starts: error_reporting(E_ALL); ini_set('display_errors', '1'); . No error is reported besides the 'magical' Segmentation fault . I'm not using APC.



Not sure if it's relevant, but I'm using CLI to run the script, not a web-interface.



PHP version is 5.3.8, MySQL version is 5.1.56. The memory limit is set to 64MB.



EDIT: The procedure failing + some of the other code is uploaded here: http://codepad.org/KkZTxttQ . The whole file is huge and ugly, and I believe irrelevant, so I'm not posting it for now. The line that's failing is 113.


Source: Tips4allCCNA FINAL EXAM

Comments

  1. An answer to my own question, since I've solved the issue, and there are no other answers...

    Credit goes to @jap1968 for pointing to me to the function mysqli_stmt_error (which I assumed I would not need, since I have error_reporting(E_ALL)).

    The problem was that MySQL had a very weird default configuration: particularly

    connect_timeout = 10
    wait_timeout = 30


    This caused the MySQL server to close the connection after only 30 seconds (default is more than a half hour, according to MySQL website). This in turn, caused the mysqli_stmt_bind_result function to fail with a Segmentation Fault.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.