Error in the core code. (attention admins)

Started by Toma Grubb, July 25, 2007, 02:20:26 PM

Previous topic - Next topic

Toma Grubb

SMF Version: SMF 1.1.3
Version Information:
Forum version: SMF 1.1.3 (more detailed)
Current SMF version: SMF 1.1.3
PHP version: 4.4.6
MySQL version: 4.1.22-standard
Server version: Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a


I was getting an error message that I found a solution for but The problem seems to be in the current release.

This was the fix I found in the forum.

original thread:http://diabetic-diet-secrets.com/members/external/community-forum.html

Quoteokay, well, i managed to fix it without uninstalling any mods at all...

the problem was that, in Sources/Display.php, when the callback prepareDisplayContext() was finished processing through $messages_request, it didn't do a mysql_free_result() on it.

why it didn't do that, and whether or not it used to and got changed not to (and when that might've happened), i can't say for sure... but now that i've changed
Code:

    // Attempt to get the next message.
    $message = mysql_fetch_assoc($messages_request);
    if (!$message)
        return false;

to
Code:

    // Attempt to get the next message.
    $message = mysql_fetch_assoc($messages_request);
    if (!$message) {
        mysql_free_result($messages_request);
        return false;
    }

OK back to the base problem I was getting an error on my server that was shutting down the server and causing my site to go down every day or so. I am on a VPS. I shut down all unnecessary services in the Web Host manager  in an attempt to stop the memory leaks and keep the site up and accessible to the public. The site hosted on the VPS that I am working on is http://www.diabetic-diet-secrets.com

That fixed some of the problem but there still seems to be a memory leak. I was getting an error that said the MyQSL was not closing. I did the upgrade to 1.1.3.
I was still getting the same error message.  I found the fix quoted above and applied it. Now the forum appears correct until you try to access a specific page.

The post are coming up with a blank page. This started happening after applying the fix quoted above.

The 1.1.3 was generating the same error code that I saw in 1.1.2. The newly installed update had this code in Sources/PersonalMessage.php which looks to me like a mistake in the core code in the 1.1.3 release.

// Attempt to get the next message.
         $message = mysql_fetch_assoc($messages_request);
         if (!$message) {
        mysql_free_result($messages_request);
        return false;
        }

so my problem is how do I get the post displaying again?


karlbenson

do you still require assistance with this?

Toma Grubb

I have figured out how to solve it for me.

I was just trying to bring attention to the admins to alert them to what I think is an error in the base code that I just happened to stumble across. I did not find a place to report bugs or code errors so I posted it here hoping I was putting it in the right place.

karlbenson

#3
There is Bug Reports

Don't worry, if necessary, I'm sure an SMF team member can move it. ;)

I don't know the context where the code lies, but instead of what is suggested, I would have wrote

    // Attempt to get the next message.
    $message = mysql_fetch_assoc($messages_request);
    mysql_free_result($messages_request);
    if (!$message) {
        return false;
    }
   


(Note the mysql_free_result is shown above the IF statement, because inside the IF statement  the mysql result would not have been freed if $message did NOT return false).
As far as I'm aware from the limit code, once $message is set to  mysql_fetch_assoc($messages_request), it should be safe to free the result.

metallica48423

i will move this to bug reports, thank you for your report :)
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

SleePy

Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

metallica48423

Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Grudge

I don't see how this can cause a server issue - PHP/MySQL will automatically clean up any unfreed results - the only reason to free it in the code is reducing memory usage during execution.

It's not really possible to add the call to free result. SMF relies on being able to call "reset" during that function; if we free the data on the end of the first execution the second one (Which does the reset) will fail.
I'm only a half geek really...

Toma Grubb

I started this thread because I was looking for a way to keep my server running. I should tell you I am a 60 year  old Trying to figure all this stuff out and basically have no clue about what I am doing.  :-[

The techs at my hosting provider told me I had memory leaks that were shutting down my VPS several times a day. I was getting an error code that pointed to SMF and trying this to solve the other problem.

SMF quit showing errors and the server ran better, but still had problems. This was just one of many errors that were causing problems.

The reason I started the thread was when I upgraded as part of the process I found code that had extraneous code that is generated when the space bar is used. I got rid of the space code and it worked. I just wanted to try to inform someone who knew what they were doing on the SMF team of the code errors.

Grudge

No worries.

Without going into too much detailed I cannot see how SMF can itself cause a memory leak. The error messages seen are more likely to be because that is simply, by chance, the point at which the server ran out of memory and stopped execution.

PHP and MySQL are both designed to "clean up" after themselves. Scripts simply call functions and if they don't clean up it's not a big deal as PHP will do it for you. It *is* possible for a script to get into an infinite loop and eat up all the memory - but that's would not be a leak.

One thing for certain is the "fix" in your first post will just leak to empty posts so is not the solution. I see it as very unlikely that it is due to a fault in SMF itself (Otherwise servers all over the place would be suffering from the same problem) so maybe it's worth checking any mods you might have installed and otherwise asking your host for more information? It's possible that they simply don't allocate you enough memory and your site is getting busy enough to eat it all up.
I'm only a half geek really...

Advertisement: