-
php 5.4 fatal error, Allowed memory size of 83886080 bytes exhausted
Hi, I upgraded a server to php 5.4 and I've been getting these php fatal errors ever since.
09-Apr-2013 05:43:33 America/Denver] PHP Fatal error: Allowed memory size of 83886080 bytes exhausted (tried to allocate 3050946969 bytes) in /home/MYDOMAIN/public_html/store/includes/functions/html_output.php on line 62
[09-Apr-2013 05:43:33 America/Denver] PHP Warning: require(includes/classes/db/mysql/query_factory.php): failed to open stream: No such file or directory in /home/MYDOMAIN/public_html/store/includes/functions/sessions.php on line 59
[09-Apr-2013 05:43:33 America/Denver] PHP Fatal error: require(): Failed opening required 'includes/classes/db/mysql/query_factory.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/MYDOMAIN/public_html/store/includes/functions/sessions.php on line 59
It's in sessions.php where there is no db object defined, so it tries to include the db class. But that is failing. Says it's a bug fix for php 5.2.
I tracked one occurrence down to a session issue with the authorize.net sim callback. In the header.php for checkout_success, I put a session_write_close() just before the exit and that stopped the fatal error in that situation. But here it is occurring again somewhere else.
In query_factory, there is a session existing when I log just before the failing include.
If I change the include to be a full file path, the include of the db class succeeds but it fails saying that class Base doesn't exist, so something is very wrong there. Some chain of includes is failing somehow.
Any ideas on how to debug this situation? I'll have to find which url is causing this fatal error and try seeing how far it's getting and where it's occurring by using error log statements. I haven't been able to cause it to happen locally, or when a debugger is attached to server. Any ideas?
Are these includes depending on the current directory set to anything in particular? I'm using php-fpm to run php from apache 2.4.
thanks much
-
Re: php 5.4 fatal error, query factory
Sounds exactly like custom code (or an addon with a bug) that's gone into an endless loop while iterating through a set of database results because it's missing the call to MoveNext() within the while() loop.
The files mentioned are merely messengers; highly unlikely they're the cause of your problem, unless you've altered them from their original contents.
-
Re: php 5.4 fatal error, query factory
Thanks, that helps, I didn't think of that - php is calling the session_write because it's killing a thread that's either timed out or used too many resources. And perhaps many of the classes are garbage at that point, overwritten in memory etc.
We don't have many customizations but I'll check them all. I don't think it's the database thing or infinite loop or we'd have problems with our store. Our store is running fine except for this random bug that occurs a few times a day. It used to only occur during the authorize.net sim callback, but now I have to track down what's causing it again.
thanks
-
Re: php 5.4 fatal error, query factory
-
Re: php 5.4 fatal error, query factory
Hi, sorry to jump in, but I'm having pretty much the same problem. I'm using Zen Cart version 1.5.1, with PHP 5.2 everything is fine, when I switch to PHP 5.4, everything is still fine apart from:
When a customer tries to log in (on "main_page=login", enters email address + password + click "log in" button) the screen goes blank. Refresh with F5 and everything is fine, they are logged in and can access orders etc. The only issue is the blank screen, and obviously customers won't know to refresh.
The log file is pretty much as above: "[09-May-2013 20:19:01 Europe/Berlin] PHP Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 746615801 bytes) in /homepages/1/d205539884/htdocs/store/includes/functions/html_output.php on line 62".
Any ideas where to start looking? The customer table in the database is only half a MB which doesn't seem too large, and I don't think there are any mods which would affect this. Also it doesn't happen at all with PHP 5.2.
-
Re: php 5.4 fatal error, query factory
I had this same Fatal Error show up on a different site with different server, different Cent OS version, and almost no cart customizations. Traced it down to the last redirect in the header.php for the login page. Was able to do a backtrace on an apache segfault core dump and saw a Zend error reading a constant. I wasn't able to debug it more w/o recompiling php with debug symbols etc etc.
Also, it seemed to depend on cookies - if I had logged in once (refresh after fatal error), then it would logout/login w/o error. But starting w/o cookies seemed to always make it error.
I was able to duplicate the crash on a virtualbox linux setup too. If I commented the code in login header.php for merging the carts, it segfaulted, if left in it was a Fatal Error. So something was hosed earlier probably. This is w/o any opcode cache. Happens with apache 2.2 and 2.4, one is DSO and one is php-fpm. So I think we have a php error showing up in 5.4.14.
Went back to php 5.3.23 and all is fine now - no errors at all. That's the only solution I know for now.
I was using php from the Remi repository for centos/redhat. When there's an update I'll try again.
here's the call trace from the segfault:
(gdb) bt
#0 0x006604f5 in ?? ()
#1 0x04c34090 in ?? () from /usr/lib/httpd/modules/libphp5.so
#2 0x04a778ff in _zval_copy_ctor_func (zvalue=0xb75d6e8c) at /usr/src/debug/php-5.4.14/Zend/zend_variables.c:123
#3 0x04abc2fb in _zval_copy_ctor (execute_data=<value optimized out>)
at /usr/src/debug/php-5.4.14/Zend/zend_variables.h:45
#4 ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER (execute_data=<value optimized out>)
at /usr/src/debug/php-5.4.14/Zend/zend_vm_execute.h:22396
#5 0x04ae64a6 in execute (op_array=0x1ad3d58) at /usr/src/debug/php-5.4.14/Zend/zend_vm_execute.h:410
-
Re: php 5.4 fatal error, query factory
Have to admit I'm a novice with this stuff and a lot of it goes over my head. One thing I've noticed which may or may not be relevant - with PHP 5.2, when a customer logs in, the page that loads up is the store home page (unless they have saved cart contents). With PHP 5.4, after the blank screen and refresh, the page that loads is "main_page=account" instead of the store home page.
Also, I have another site with the same server settings, zen cart 1.5.1 again, more or less the same zen cart settings + mods, but works fine on PHP 5.4. Logging in brings up the store home page on that site.
I've tried deleting all CUSTOM template files so the defaults were used, still the same problem. I've looked at files in the modules/pages folders for the login + account pages, compared them to the other site which works ok, and there are no differences.
I'm completely stumped now. I was hoping to switch to PHP 5.4 so I can upgrade to a different hosting package, which doesn't support older versions of PHP. So frustrating as this is the only thing holding me back. :huh:
-
Re: php 5.4 fatal error, query factory
Just realised my last post was pretty useless, sorry. Login takes the customer back to where they were before, so in my case shop home page. F5 on the blank login screen takes the customer to their account page, as that is what is supposed to happen if someone tries to "log in" while already logged in. :blush:
So the question is, what causes the blank page error after login, even though the login works (they are logged in after F5 refresh)?
-
Re: php 5.4 fatal error, query factory
you need to check your php error log files and see what they say. with 1.5.1 it's in the logs folder.
If there's no errors, it may be that apache crashed and that would be in the system error logs - your host should be able to tell you where to find those.
-
Re: php 5.4 fatal error, query factory
The error log is the same as mentioned in my first post.
The problem seems to be caused when, after login, the user is redirected back to the page they were on. I've managed to get around it for now by redirecting them to their account page after login, in the block of code that starts with:
Code:
if (sizeof($_SESSION['navigation']->snapshot) > 0) {
Something somewhere seems to be messing up the "snapshot", but I've no idea what could cause that. The website I am having this problem with uses the Zen Lightbox 1.6.4 mod. The other website that doesn't have this problem, doesn't have that mod. I read somewhere that people with that mod sometimes have problems with cookies. Do you by any chance have that lightbox mod installed?
-
Re: php 5.4 fatal error, query factory
I've seen something similar to this during plugin development (i.e. self-induced) and was able to ultimately work-around the issue by clearing the session cookies for the site. Please note that I said "work-around", not solution!
You can see, without any special debuggers, what's going on in the store by installing the Zen Cart Notifier Trace (http://www.zen-cart.com/downloads.php?do=file&id=1114) and then try logging in. Be sure to go back to your admin once you've captured the set of notifiers and turn the Notifier Trace off (Configuration->Logging) because the file can grow very large very quickly ... especially with the condition you're describing.
The plugin creates a file in your /cache folder named notifier_trace.log and contains a list of all the page-level processing that's transpired.
-
Re: php 5.4 fatal error, query factory
I had the same problem with one of the errors mentioned at the top of this thread:
[18-Aug-2013 06:25:53 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 3715690265 bytes) in /home/xxxxxxx/public_html/includes/functions/html_output.php on line 62
BRAND NEW install of Zen Cart 1.5.1 - no mods - clean database.
What worked for me to get rid of the problem with getting a blank page when trying to log in was to go to Configuration>Sessions>Force Cookie Use and change it to True
Once I did that, no more problems with logging in
Hope this helps someone!
-
Re: php 5.4 fatal error, query factory
Found and Fixed!
The problem is that when php shuts down global variables might already have been deleted when the default session write and close happens. There doesn't seem to be any synchronization between the two processes. Here are the php bug tickets regarding this:
This has all the pertinant info:
https://bugs.php.net/bug.php?id=54157
http://www.mediawiki.org/wiki/Specia...i/83140#c14601
Quote:
On request shutdown, PHP does things in the following order:
register_shutdown_function() functions
zend_call_destructors()
zend_deactivate_modules()
zend_call_destructors() goes through the $GLOBALS symbol table and identifies every global variable that holds an object which has a reference count of 1. It removes these globals. It doesn't decrement any reference counts. Any globals which are not objects, or have a reference count greater than 1, are left in the symbol table.
I believe the "fixes" that have worked for people have simply moved the symbol table around enough that the global $db is still active when session_write is called in zencart.
The fix is to set a shutdown function that does a session write close itself:
Code:
register_shutdown_function('zc_shutdown');
function zc_shutdown() {
// other shutdown code as needed
// write session now
session_write_close();
}
Then in includes/functions/sessions.php, in _sess_write, change to:
Code:
if (!is_object($db)) {
//error_log('session write with no global db variable! sessions.php .60');
// https://bugs.php.net/bug.php?id=54157
// session could be closed with no global variables
// if so, just exit, nothing we can do
// workaround is to register shutdown function that saves session
// and this last call is no-op
return;
//PHP 5.2.0 bug workaround ...
// if (!class_exists('queryFactory')) require('includes/classes/db/' .DB_TYPE . '/query_factory.php');
// $db = new queryFactory();
// $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false);
}
If we come upon a session write where we don't have global variables, it's probably because they've been destroyed. This is OK because we have already done a session write in our shutdown function, so we can ignore this session write. Of course, do not set any session variables after the shutdown function is called.
This has worked in two cases where I had this strange "session write with no global $db" value in php 5.3 and 5.4.
-
Re: php 5.4 fatal error, query factory
-
Re: php 5.4 fatal error, query factory
I downloaded the github code and saved that version of /includes/functions/sessions.php to my otherwise unmodified ZC v1.5.1 test site running PHP 5.4.21. I've got the replication of this down to a time-consuming couple of steps:
- Make sure that you are logged out of the store
- Click Login, then the "Password Forgotten" link. Enter your email address and request a new password.
- Wait for the 24-minute (I usually waited an hour to be sure) session timeout to expire.
- From the login page (where you were redirected after confirming the forgotten password), enter your email address and the password you received in the email.
- You're redirected to the time_out page because the session expired. Enter your email address and new password and press Enter.
- Experience the whitescreen experience. The log that's created is "memory exhausted" by html_output.php.
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
lat9
I downloaded the github code and saved that version of /includes/functions/sessions.php to my otherwise unmodified ZC v1.5.1 test site running PHP 5.4.21. I've got the replication of this down to a time-consuming couple of steps:
- Make sure that you are logged out of the store
- Click Login, then the "Password Forgotten" link. Enter your email address and request a new password.
- Wait for the 24-minute (I usually waited an hour to be sure) session timeout to expire.
- From the login page (where you were redirected after confirming the forgotten password), enter your email address and the password you received in the email.
- You're redirected to the time_out page because the session expired. Enter your email address and new password and press Enter.
- Experience the whitescreen experience. The log that's created is "memory exhausted" by html_output.php.
So, in another thread, one of the ZC knowledgeable suggested the following thread for a memory issue. My apologies if it happens to lead back here or to the same suggested fixes as in here. Trying to provide some input where I've seen a similarity.
http://www.zen-cart.com/showthread.p...ytes-exhausted
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
mc12345678
So, in another thread, one of the ZC knowledgeable suggested the following thread for a memory issue. My apologies if it happens to lead back here or to the same suggested fixes as in here. Trying to provide some input where I've seen a similarity.
http://www.zen-cart.com/showthread.p...ytes-exhausted
Right, the reason for my post is that the code update to /includes/functions/sessions.php referenced by both this and the post you indicated might correct "part" of the problem, but the 'memory exhausted' issue is still there even with the code update.
The log I received was
Code:
[22-Nov-2013 13:14:55 America/New_York] PHP Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 746619897 bytes) in xxx/includes/functions/html_output.php on line 62
... the referenced line being the relatively innocuous
Code:
if (defined('SID') && zen_not_null(SID)) {
-
Re: php 5.4 fatal error, query factory
Can you install Xdebug (http://www.xdebug.org/) on your server? It prints a call stack whenever there is a fatal error so you can see the function path to the crash. If the crash is not in session_write then you might have a different crash issue. I'll see if I can test this too soon.
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
avibodha
Can you install Xdebug (
http://www.xdebug.org/) on your server? It prints a call stack whenever there is a fatal error so you can see the function path to the crash. If the crash is not in session_write then you might have a different crash issue. I'll see if I can test this too soon.
It's going to be "difficult" to get this installed on my host. I did install it on my localhost (xampp) environment (PHP 5.4.8) on my Windows 7 machine. Going through the same sequence in that environment (my test installation for the failing Linux-hosted store) results in no error, so it's either a PHP version or Linux vs. Windows session-handling issue. In both cases, I used the most recent version of FireFox as the browser.
If it will help, I can PM you a copy of the phpinfo() from the failing hosted environment ...
-
Re: php 5.4 fatal error, query factory
I also started experiencing same problem after I migrated to Godaddy unlimited shared hosting from another Godaddy hosting. I copied fixed version of "session.php" from github. But problem persist. FYI: My zen cart version is 1.51
Here is error message from Godaddy when I try to login. It stuck on below blank page.
/index.php?main_page=login&action=process
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
"
Here is Zen cart log.
[26-Nov-2013 01:24:40 UTC] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 693694233 bytes) in /home/xxxxx/public_html/includes/functions/html_output.php on line 62
"
Is there any other fix?
Quote:
Originally Posted by
DrByte
-
Re: php 5.4 fatal error, query factory
I also started experiencing same problem after I migrated to Godaddy "Ultimate" shared hosting from another Godaddy hosting. I copied fixed version of "session.php" from github. But problem persist. FYI: My zen cart version is 1.51
Here is error message from Godaddy when I try to login. It stuck on below blank page.
/index.php?main_page=login&action=process
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
"
Here is Zen cart log.
[26-Nov-2013 01:24:40 UTC] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 693694233 bytes) in /home/xxxxx/public_html/includes/functions/html_output.php on line 62
"
Is there any other fix?
Quote:
Originally Posted by
DrByte
-
Re: php 5.4 fatal error, query factory
Since the code that was causing this problem in sessions.php was removed, you'll need to find where html_output.php is getting called.
You can either install the Xdebug module which will automatically log a stack trace on errors or you could try and put debug_backtrace() in the register_shutdown_function() that's in the new session.php. Post what you find.
-
Re: php 5.4 fatal error, query factory
I got the same "PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1605959449 bytes) in /home2/zzzzz/public_html/includes/functions/html_output.php on line 77" error. I changed session.php as Dr. Byte pointed out. The error still exists.
This just happened when my host removed php 5.3 and forced us to use either php 5.4 or 5.2 two days ago. When I choose php 5.4, the customer login became blank after all the user name password stuff. In the log folder, I can find the above error log. However, if I switch to 5.2, the problem went away. It seems that this problem is php version related. I talked with my host and was told that they are going to pull away php 5.2 very soon. Therefore, we have to find a solution to this error before they do that. Please post your solution if you have solved this problem. Thank you!
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
kagaroo
I got the same "PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1605959449 bytes) in /home2/zzzzz/public_html/includes/functions/html_output.php on line 77" error. I changed session.php as Dr. Byte pointed out. The error still exists.
This just happened when my host removed php 5.3 and forced us to use either php 5.4 or 5.2 two days ago. When I choose php 5.4, the customer login became blank after all the user name password stuff. In the log folder, I can find the above error log. However, if I switch to 5.2, the problem went away. It seems that this problem is php version related. I talked with my host and was told that they are going to pull away php 5.2 very soon. Therefore, we have to find a solution to this error before they do that. Please post your solution if you have solved this problem. Thank you!
PHP 5.2 and 5.3 have reached end of life.
You may have some custom coding in your install which does not cope well with PHP > 5.2
Try and install a demo vanilla ZC 1.5.1 version on your server somewhere in a subdirectory, switch to PHP 5.4 and see what happens. I bet you won't have a problem with the demo install. But if you do, then that could be due to server configs.
-
Re: php 5.4 fatal error, query factory
Just fresh install zc 1.51 version on my server and test as frank18 suggested. Yes, no problem, I can log in without any problem.
For my site, it was originally for the zc 1.38 and recently upgraded to zc 1.51. It was running smoothly on php 5.2 or 5.3. but not on php5.4.
When switch to php5.4, there two files seems to have problem when customers try to log in.
includes/functions/html_output.php on line 77
includes/classes/seo.url.php on line 215
Both line has the same code nearby.
Code:
if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
if (defined('SID') && zen_not_null(SID)) {
$sid = SID;
I have ultimate seo url module installed. But I still get the same error when I disable seo module.
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
kagaroo
Just fresh install zc 1.51 version on my server and test as frank18 suggested. Yes, no problem, I can log in without any problem.
... as predicted :smile:
Quote:
Originally Posted by
kagaroo
For my site, it was originally for the zc 1.38 and recently upgraded to zc 1.51. It was running smoothly on php 5.2 or 5.3. but not on php5.4.
When switch to php5.4, there two files seems to have problem when customers try to log in.
includes/functions/html_output.php on line 77
includes/classes/seo.url.php on line 215
Both line has the same code nearby.
Code:
if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
if (defined('SID') && zen_not_null(SID)) {
$sid = SID;
I have ultimate seo url module installed. But I still get the same error when I disable seo module.
I would now install ultimate seo on the new demo site and then test again if it works on PHP 5.4
If it does, then compare your live site to your demo site - you may be able to find the piece of code which causes you trouble with PHP 5.4
-
Re: php 5.4 fatal error, query factory
Read the previous messages, the sympton of my site is exactly like WayneStephens in the first page. If customers have some merchandise in the shopping cart, then there is no problem to login and the page will be directed to shopping cart page again. However, if customers try to login from the homepage without any merchandise in the shopping cart, then error will ocurr with a blank page and refreshing this blank page will direct the customer to the account page and not the page where they come from. It seems that the following statement in login page header_php.php is not processed correctly in php 5.4, at least in my site.
Code:
$origin_href = zen_href_link($_SESSION['navigation']->snapshot['page'], zen_array_to_string($_SESSION['navigation']->snapshot['get'], array(zen_session_name())), $_SESSION['navigation']->snapshot['mode']);
There is nothing to do with seo, at least from what I observed. Since disable seo, the same problem occurs
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
kagaroo
... If customers have some merchandise in the shopping cart, then there is no problem to login and the page will be directed to shopping cart page again. However, if customers try to login from the homepage without any merchandise in the shopping cart, then error will ocurr with a blank page and refreshing this blank page will direct the customer to the account page and not the page where they come from. ...
I've been running Zen Cart 1.5.1 w/ USU for a few months on a hosted site running Apache2 / PHP 5.4.22 / MySQL 5.5.30. I also have test environments on Apache2 / PHP 5.4.4 / MySQL 5.5.31 and Apache2 / PHP 5.4.12 / MySQL 5.5.28 running Zen Cart 1.5.1 w/ USU... I have not yet applied the "sessions patch" to any of them...
Have not received any memory size exhausted messages yet... Tried the steps posted by lat9... Tried also making sure I was logged out, going to a product page (adds the snapshot), and finally a login (triggers that line of code). I am unable to duplicate the error on any of the above mentioned sites... :-(
Can you post the Web Server / PHP / MySQL versions on your hosting provider? Your settings for "configuration" -> "sessions" (I have all still at out of box settings - except the live site which has force cookies enabled)? The settings for PHP "sessions" (found in the Zen Cart Administrative interface under "version" for PHP)? Hosting Provider? Any caching being done by the hosting provider?
Hoping we might see a pattern for those still experiencing this issue...
-
Re: php 5.4 fatal error, query factory
Hi, Ihungil, thank you for your time. I was just frustrated after switched to php 5.4. Here is the info you asked:
MySQL 5.5.34
PHP Version: 5.4.20
HTTP Server: Apache
Server OS: Linux 2.6.32
Provider:Bluehost
session setting in php version (just master value)
session.auto_start Off
session.cache_expire 180
session.cache_limiter nocache
session.cookie_domain no value
session.cookie_httponly Off
session.cookie_lifetime 0
session.cookie_path /
session.cookie_secure Off
session.entropy_file /dev/urandom
session.entropy_length 0
session.gc_divisor 1000
session.gc_maxlifetime 1440
session.gc_probability 1
session.hash_bits_per_character 5
session.hash_function 1
session.name PHPSESSID
session.referer_check no value
session.save_handler files
session.save_path /tmp
session.serialize_handler php
session.upload_progress.cleanup On
session.upload_progress.enabled On
session.upload_progress.freq 1%
session.upload_progress.min_freq 1
session.upload_progress.name PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix upload_progress_
session.use_cookies On
session.use_only_cookies On
session.use_trans_sid 0
session setting in admin:
Session Directory /home2/zzzzz/public_html/cache
Cookie Domain True
Force Cookie Use False
Check SSL Session ID False
Check User Agent False
Check IP Address False
Prevent Spider Sessions True
Recreate Session True
IP to Host Conversion Status true
Use root path for cookie path False
Add period prefix to cookie domain True
-
Re: php 5.4 fatal error, query factory
Here's the configuration for the installation that was failing:
PHP: 5.4.21
MySQL: 5.1.72
Server OS: Linux 2.6.28.8-20120713a-iscsi-ntacker-3ware-sec8-fmon-igb-dif2-grsec
HTTP Server: Apache
Provider: 1and1
Code:
session
Session Support enabled
Registered save handlers files user sqlite
Registered serializer handlers php php_binary wddx
Directive Local Value Master Value
session.auto_start Off Off
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain .mystore.com no value
session.cookie_httponly On Off
session.cookie_lifetime 0 0
session.cookie_path /myadmin /
session.cookie_secure Off Off
session.entropy_file /dev/urandom /dev/urandom
session.entropy_length 32 32
session.gc_divisor 2 100
session.gc_maxlifetime 900 1440
session.gc_probability 1 1
session.hash_bits_per_character 4 4
session.hash_function 0 0
session.name zenAdminID PHPSESSID
session.referer_check no value no value
session.save_handler user files
session.save_path /mystore/cache /tmp
session.serialize_handler php php
session.upload_progress.cleanup On On
session.upload_progress.enabled On On
session.upload_progress.freq 1% 1%
session.upload_progress.min_freq 1 1
session.upload_progress.name PHP_SESSION_UPLOAD_PROGRESS PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix upload_progress_ upload_progress_
session.use_cookies On On
session.use_only_cookies On On
session.use_trans_sid 0 0
Code:
Session Directory /mystore/cache
Cookie Domain True
Force Cookie Use False
Check SSL Session ID False
Check User Agent False
Check IP Address False
Prevent Spider Sessions True
Recreate Session True
IP to Host Conversion Status true
Use root path for cookie path False
Add period prefix to cookie domain True
-
Re: php 5.4 fatal error, Allowed memory size of 83886080 bytes exhausted
Nothing jumping out to me :(
Server1 OS: Linux 2.6.32-358.18.1.el6.x86_64
Server2 OS: Linux 3.2.0-2-amd64
Both have the same settings for PHP sessions (other then default session.save_path)
Code:
Session Support enabled
Registered save handlers files user mm
Registered serializer handlers php php_binary wddx
Directive Local Value Master Value
session.auto_start Off Off
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain .mystore.com no value
session.cookie_httponly On Off
session.cookie_lifetime 0 0
session.cookie_path /myadmin /
session.cookie_secure Off Off
session.entropy_file /dev/urandom /dev/urandom
session.entropy_length 32 32
session.gc_divisor 2 1000
session.gc_maxlifetime 900 1440
session.gc_probability 1 0
session.hash_bits_per_character 5 5
session.hash_function 0 0
session.name zenAdminID PHPSESSID
session.referer_check no value no value
session.save_handler user files
session.save_path /home/user/cache /tmp
session.serialize_handler php php
session.upload_progress.cleanup On On
session.upload_progress.enabled On On
session.upload_progress.freq 1% 1%
session.upload_progress.min_freq 1 1
session.upload_progress.name PHP_SESSION_UPLOAD_PROGRESS PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix upload_progress_ upload_progress_
session.use_cookies On On
session.use_only_cookies On On
session.use_trans_sid 0 0
-
Re: php 5.4 fatal error, Allowed memory size of 83886080 bytes exhausted
Not supprise. I have a fresh installed zc1.51 under php5.4 in the same server with no issue. It is not the setting of the server, it is the code which causing the problem. We just don't know which custom code can triger this type error and would like inside person help us to pinpoint the problem.
-
Re: php 5.4 fatal error, Allowed memory size of 83886080 bytes exhausted
I just read the requirement for zc 1.51.
Quote:
Zen Cart v1.5.1 is compatible with PHP 5.2.14 thru PHP 5.3.x. Requires some patches to work with PHP 5.4.
Can anyone point to me which patch it refers to? Thanks!
-
Re: php 5.4 fatal error, Allowed memory size of 83886080 bytes exhausted
Don't know where you read that. Quoting the requirements from the docs folder in a 1.5.1 release.
Quote:
Minimum Server Requirements:- * PHP 5.2.14 or higher, Apache 2.0 or higher, and MySQL 4.1.3 or higher.
- * Apache must be configured with AllowOverride set to either 'All' or at least both 'Limit' and 'Indexes' parameters, and preferably the 'Options' parameter as well.
- * PHP must be configured to support CURL with OpenSSL
RECOMMENDED server capabilities:- PHP 5.3.5 or higher
- Apache 2.0 or higher
- MySQL 5.0.90 or higher
- and the Apache/PHP configuration settings mentioned above.
While Zen CartŪ can run on Windows/IIS servers,
Linux/Apache servers are recommended for best results.
-
Re: php 5.4 fatal error, Allowed memory size of 83886080 bytes exhausted
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
kagaroo
Just fresh install zc 1.51 version on my server and test as frank18 suggested. Yes, no problem, I can log in without any problem.
For my site, it was originally for the zc 1.38 and recently upgraded to zc 1.51. It was running smoothly on php 5.2 or 5.3. but not on php5.4.......
I am suspecting that you still have some "left overs" from zc 1.3.8 in your upgraded zc 1.5.1 installation. The fact that you had no memory problems with a vanilla 1.5.1 install on the same server seems to confirm that theory.
Somehow somewhere your upgraded install is running into a loop which exhausts your memory - no matter how high you set the limit.
Do a thorough check of your file system or do a brand new re-build of your site with 1.5.1 which contains no traces of 1.3.8 code. Alternatively you could hire someone to do this job for you.
Cheers/Frank
-
Re: php 5.4 fatal error, query factory
The problem was solved when I chose "$add_session_id=false" in both seo.url.php and html_output.php. The insteresting thing is that the freshly installed zc 1.51 could work even when "$add_session_id=true" was chosen.
Is there any problem if I chose "$add_session_id=false"?
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
kagaroo
The problem was solved when I chose "$add_session_id=false" in both seo.url.php and html_output.php. The insteresting thing is that the freshly installed zc 1.51 could work even when "$add_session_id=true" was chosen.
See my post above:
Quote:
I am suspecting that you still have some "left overs" from zc 1.3.8 in your upgraded zc 1.5.1 installation.....
It would be a matter of finding these 1.3.8 remnants and eliminating that code - wherever it may be.:huh:
Quote:
Originally Posted by
kagaroo
Is there any problem if I chose "$add_session_id=false"?
I am afraid I can't assist with an answer to that question.
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
lat9
The log I received was
Code:
[22-Nov-2013 13:14:55 America/New_York] PHP Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 746619897 bytes) in xxx/includes/functions/html_output.php on line 62
... the referenced line being the relatively innocuous
Code:
if (defined('SID') && zen_not_null(SID)) {
Still having this issue. I don't know if use of the pre-defined constant 'SID' is part of the issue, based on the comment in this (http://www.php.net/manual/en/session.constants.php) page at php.net. My php.ini sets both session.use_cookies and session.use_only_cookies to 'On' and I have been refreshing the screen, trying to get past the login whitescreen, using FireFox 25.0.1.
-
Re: php 5.4 fatal error, query factory
If I make changes as you did "$add_session_id=false" then does it compromise my website security? Does it have any other side effects?
This blank screen problem really bothering me.
Quote:
Originally Posted by
kagaroo
The problem was solved when I chose "$add_session_id=false" in both seo.url.php and html_output.php. The insteresting thing is that the freshly installed zc 1.51 could work even when "$add_session_id=true" was chosen.
Is there any problem if I chose "$add_session_id=false"?
-
Re: php 5.4 fatal error, query factory
gsmsalers, that was the exact question I wanted to ask zen-cart experts.
-
Re: php 5.4 fatal error, query factory
The only side effect I see of $add_session_id=false is if you have a different host for your SSL connection. If they are different, and the user's cookies don't work (a rare occurence), the session would not be carried over to the ssl connection. Otherwise it won't have any effect.
It would be good to find out where this problem is coming from. Can you install xDebug on your server? That will give a stack trace for this error that would help to debug the cause.
-
Re: php 5.4 fatal error, query factory
Avibodha, thank you for your info. At least your answer make me feel much better. As for xdebug, I haven't install it and may give it a shot when I have time.
-
Re: php 5.4 fatal error, query factory
Back again on this.:( I inserted a write to the error log in /includes/functions/html_output.php, just before the SID-related failure and the debug_backtrace showed index.php requiring /includes/modules/pages/login/header_php.php which subsequently called the zen_redirect function. FWIW, I broke up the combined statement like this:
Code:
// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
$val1 = defined ('SID');
$val2 = $val1 && SID != '';
... the out-of-memory error is occurring on the highlighted statement. I'd love to get xdebug installed to see what's up, but the (non-)technical support staff at 1&1 are hard enough to communicate with on simple issues. No problems logging into the admin, but I'll be :censored: if I can get logged into the store-side.
Again, I've got the v1.5.2/v1.6.0 changes to the sessions handling installed on an otherwise clean v1.5.1 fileset.
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
lat9
... Again, I've got the v1.5.2/v1.6.0 changes to the sessions handling installed on an otherwise clean v1.5.1 fileset.
I went back to (actually) look at what I had installed -- as opposed to what I thought was installed -- and it turns out that I'd installed a couple of observer-class plugins (notifier trace, report all errors) to try to figure out what was up. I disabled (via file-extension rename) the load of these plugins and I'm able to log in. Add them back, no login. Rename one -- doesn't matter which -- login. Hmm.:dontgetit
I've also got the ZC 1.5.2-RC2 version of /includes/classes/class.base.php loaded. The site is running PHP 5.4.25.
I'm just wondering if this has anything to do with the pass-by-reference deprecation in PHP 5.4, since the attach function of the base class is passing a reference to the observer for later use:
Code:
function attach(&$observer, $eventIDArray) {
foreach($eventIDArray as $eventID) {
$nameHash = md5(get_class($observer).$eventID);
base::setStaticObserver($nameHash, array('obs'=>&$observer, 'eventID'=>$eventID));
}
}
-
Re: php 5.4 fatal error, query factory
The thing deprecated in 5.4 was forcing a pass-by-reference in a function call. http://www.php.net/manual/en/languag...ences.pass.php
The attach function is only assigning a reference to an object ($observer) to an array item. So I don't think this would cause a fatal error by itself. I don't know what the cause of the the problem you're seeing.
From what I've seen, the cause of these crashes is never actually in html_output, something has been corrupted way before that. If you have any zen_redirect, try putting session_write_close() before them. I think you need more access to your server to do much more debugging. (xdebug, etc).
You could try with an empty observer class and see if that works, then add back up code till it crashes again.
-
Re: php 5.4 fatal error, query factory
Thanks, avibodha. I'm just grasping at straws at this point. I'll post back if I find anything.
-
Re: php 5.4 fatal error, query factory
Not that this change made any difference in my situation, but shouldn't the static observer value be initialized on first use? The first time an attach request is received, the value's NULL:
Code:
function setStaticObserver($element, $value)
{
$observer = & base::getStaticObserver();
if (!is_array($observer)) {
$observer = array ();
}
$observer[$element] = $value;
}
-
Re: php 5.4 fatal error, query factory
OK, here's a weird one. I got the "memory exhausted" error running in a localhost environment and thought "aha!" now I can get that debug package loaded! Looking at the line that resulted in the error
Code:
$height_inches = array ( array ( 'id' => '-1', 'text' => TEXT_PLEASE_CHOOSE ) );
for ($i = 0; i < 12; $i++) {
$height_inches[] = array ( 'id' => $i, 'text' => $i );
}
I noticed that the comparison portion was missing its $
Code:
$height_inches = array ( array ( 'id' => '-1', 'text' => TEXT_PLEASE_CHOOSE ) );
for ($i = 0; $i < 12; $i++) {
$height_inches[] = array ( 'id' => $i, 'text' => $i );
}
Why the heck would that have triggered an out-of-memory condition? Shouldn't a parse error have been asserted instead? PHP 5.4.8
-
Re: php 5.4 fatal error, query factory
Good catch!
If there is no $ in front of a variable, php treats it as a defined constant.
What page is this from?
I have no idea how a compare to 12 would work, but obviously it was less and kept adding to the array till you ran out of memory. Could you post this to bug fixes?
I would have expected that this would give you a message like "tried to allocate (small number) of bytes and failed", instead of trying to allocate random huge number of bytes like the other errors.
-
Re: php 5.4 fatal error, query factory
avibodha, it came from some code that I'm developing. I'm guessing that since the constant i was not defined, it was treated as 0 so the for-loop was, essentially, infinite thus resulting in the out-of-memory condition.
I'll certainly post my finding, but I'm already anticipating the result ... won't fix.
-
Re: php 5.4 fatal error, query factory
Hi,
Sorry it's taken so long to address this. Totally agree with your fix. Expect to see it rolled into 152/1.6 shortly
Quote:
Originally Posted by
lat9
Not that this change made any difference in my situation, but shouldn't the static observer value be initialized on first use? The first time an attach request is received, the value's NULL:
Code:
function setStaticObserver($element, $value)
{
$observer = & base::getStaticObserver();
if (!is_array($observer)) {
$observer = array ();
}
$observer[$element] = $value;
}
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
lat9
OK, here's a weird one. I got the "memory exhausted" error running in a localhost environment and thought "aha!" now I can get that debug package loaded! Looking at the line that resulted in the error
Code:
$height_inches = array ( array ( 'id' => '-1', 'text' => TEXT_PLEASE_CHOOSE ) );
for ($i = 0; i < 12; $i++) {
$height_inches[] = array ( 'id' => $i, 'text' => $i );
}
I noticed that the comparison portion was missing its $
Code:
$height_inches = array ( array ( 'id' => '-1', 'text' => TEXT_PLEASE_CHOOSE ) );
for ($i = 0; $i < 12; $i++) {
$height_inches[] = array ( 'id' => $i, 'text' => $i );
}
Why the heck would that have triggered an out-of-memory condition? Shouldn't a parse error have been asserted instead? PHP 5.4.8
Quote:
Originally Posted by
avibodha
Good catch!
If there is no $ in front of a variable, php treats it as a defined constant.
What page is this from?
I have no idea how a compare to 12 would work, but obviously it was less and kept adding to the array till you ran out of memory. Could you post this to bug fixes?
I would have expected that this would give you a message like "tried to allocate (small number) of bytes and failed", instead of trying to allocate random huge number of bytes like the other errors.
Quote:
Originally Posted by
lat9
avibodha, it came from some code that I'm developing. I'm guessing that since the constant i was not defined, it was treated as 0 so the for-loop was, essentially, infinite thus resulting in the out-of-memory condition.
I'll certainly post my finding, but I'm already anticipating the result ... won't fix.
1. As lat9 posted, it would run out of memory because the loop would never complete, since i is treated as a constant (and since uninitialized its value would evaluate to 0 or 1), and never increment to 12 or more. So the loop becomes endless.
2. No point filing it as a ZC bug report, since that code doesn't come from Zen Cart core code. There is no mention of "height_inches" anywhere in Zen Cart.
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
avibodha
Hi, I upgraded a server to php 5.4 and I've been getting these php fatal errors ever since.
09-Apr-2013 05:43:33 America/Denver] PHP Fatal error: Allowed memory size of 83886080 bytes exhausted (tried to allocate 3050946969 bytes) in /home/MYDOMAIN/public_html/store/includes/functions/html_output.php on line 62
[09-Apr-2013 05:43:33 America/Denver] PHP Warning: require(includes/classes/db/mysql/query_factory.php): failed to open stream: No such file or directory in /home/MYDOMAIN/public_html/store/includes/functions/sessions.php on line 59
[09-Apr-2013 05:43:33 America/Denver] PHP Fatal error: require(): Failed opening required 'includes/classes/db/mysql/query_factory.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/MYDOMAIN/public_html/store/includes/functions/sessions.php on line 59
It's in sessions.php where there is no db object defined, so it tries to include the db class. But that is failing. Says it's a bug fix for php 5.2.
I tracked one occurrence down to a session issue with the authorize.net sim callback. In the header.php for checkout_success, I put a session_write_close() just before the exit and that stopped the fatal error in that situation. But here it is occurring again somewhere else.
In query_factory, there is a session existing when I log just before the failing include.
If I change the include to be a full file path, the include of the db class succeeds but it fails saying that class Base doesn't exist, so something is very wrong there. Some chain of includes is failing somehow.
Any ideas on how to debug this situation? I'll have to find which url is causing this fatal error and try seeing how far it's getting and where it's occurring by using error log statements. I haven't been able to cause it to happen locally, or when a debugger is attached to server. Any ideas?
Are these includes depending on the current directory set to anything in particular? I'm using php-fpm to run php from apache 2.4.
thanks much
Quote:
Originally Posted by
stellarweb
I had the same problem with one of the errors mentioned at the top of this thread:
[18-Aug-2013 06:25:53 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 3715690265 bytes) in /home/xxxxxxx/public_html/includes/functions/html_output.php on line 62
BRAND NEW install of Zen Cart 1.5.1 - no mods - clean database.
What worked for me to get rid of the problem with getting a blank page when trying to log in was to go to Configuration>Sessions>Force Cookie Use and change it to True
Once I did that, no more problems with logging in
Hope this helps someone!
Quote:
Originally Posted by
lat9
I downloaded the github code and saved that version of /includes/functions/sessions.php to my otherwise unmodified ZC v1.5.1 test site running PHP 5.4.21. I've got the replication of this down to a time-consuming couple of steps:
- Make sure that you are logged out of the store
- Click Login, then the "Password Forgotten" link. Enter your email address and request a new password.
- Wait for the 24-minute (I usually waited an hour to be sure) session timeout to expire.
- From the login page (where you were redirected after confirming the forgotten password), enter your email address and the password you received in the email.
- You're redirected to the time_out page because the session expired. Enter your email address and new password and press Enter.
- Experience the whitescreen experience. The log that's created is "memory exhausted" by html_output.php.
Quote:
Originally Posted by
lat9
Right, the reason for my post is that the code update to /includes/functions/sessions.php referenced by both this and the post you indicated might correct "part" of the problem, but the 'memory exhausted' issue is still there even with the code update.
The log I received was
Code:
[22-Nov-2013 13:14:55 America/New_York] PHP Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 746619897 bytes) in xxx/includes/functions/html_output.php on line 62
... the referenced line being the relatively innocuous
Code:
if (defined('SID') && zen_not_null(SID)) {
Quote:
Originally Posted by
gsmsalers
I also started experiencing same problem after I migrated to Godaddy "Ultimate" shared hosting from another Godaddy hosting. I copied fixed version of "session.php" from github. But problem persist. FYI: My zen cart version is 1.51
Here is error message from Godaddy when I try to login. It stuck on below blank page.
/index.php?main_page=login&action=process
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at
[email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
"
Here is Zen cart log.
[26-Nov-2013 01:24:40 UTC] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 693694233 bytes) in /home/xxxxx/public_html/includes/functions/html_output.php on line 62
"
Is there any other fix?
Quote:
Originally Posted by
kagaroo
Just fresh install zc 1.51 version on my server and test as frank18 suggested. Yes, no problem, I can log in without any problem.
For my site, it was originally for the zc 1.38 and recently upgraded to zc 1.51. It was running smoothly on php 5.2 or 5.3. but not on php5.4.
When switch to php5.4, there two files seems to have problem when customers try to log in.
includes/functions/html_output.php on line 77
includes/classes/seo.url.php on line 215
Both line has the same code nearby.
Code:
if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
if (defined('SID') && zen_not_null(SID)) {
$sid = SID;
I have ultimate seo url module installed. But I still get the same error when I disable seo module.
I've been able to replicate the problem. PHP 5.4.21
It does appear to be something very odd with whatever PHP is doing in the background regarding the predefined SID constant.
Making the following change to lines 62-63 seems to bypass the problem and appears to have stopped triggering the PHP out-of-memory condition:
Code:
if (defined('SID') && zen_not_null(constant('SID'))) {
$sid = constant('SID');
I'd be very interested in hearing your results after applying this change.
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
lat9
avibodha, it came from some code that I'm developing. I'm guessing that since the constant i was not defined, it was treated as 0 so the for-loop was, essentially, infinite thus resulting in the out-of-memory condition.
I'll certainly post my finding, but I'm already anticipating the result ... won't fix.
Found this report as a duplicate (https://bugs.php.net/bug.php?id=50331&edit=2); enabling error-reporting for "Notice" type errors would have shown it up!
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
DrByte
I've been able to replicate the problem. PHP 5.4.21
It does appear to be something very odd with whatever PHP is doing in the background regarding the predefined SID constant.
Making the following change to lines 62-63 seems to bypass the problem and appears to have stopped triggering the PHP out-of-memory condition:
Code:
if (defined('SID') && zen_not_null(constant('SID'))) {
$sid = constant('SID');
I'd be very interested in hearing your results after applying this change.
Most excellent, DrByte! I'll apply those changes to the test-site that was experiencing those issues and let you know! Thanks for looking into this, I was starting to think that it was solely an issue with good ol' 1&1.
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
lat9
Most excellent, DrByte! I'll apply those changes to the test-site that was experiencing those issues and let you know! Thanks for looking into this, I was starting to think that it was solely an issue with good ol' 1&1.
Woo-hoo! I went to my problematic test sub-domain and attempted to login, receiving the OOM error. FTP'd up the proposed changes, clicked Refresh ... and I successfully logged in. Logged out, logged in again.:smile:
I'll keep an eye on it, but it looks like (as always) you hit the nail on the head, DrByte!
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
DrByte
I've been able to replicate the problem. PHP 5.4.21
It does appear to be something very odd with whatever PHP is doing in the background regarding the predefined SID constant.
Making the following change to lines 62-63 seems to bypass the problem and appears to have stopped triggering the PHP out-of-memory condition:
Code:
if (defined('SID') && zen_not_null(constant('SID'))) {
$sid = constant('SID');
I'd be very interested in hearing your results after applying this change.
DrByte
your fix worked for me with the same out of memory issue. zen cart 1.5.1 php 5.4.28. At the same time the error was also being generated using the ultimate seo url mod 2.212. The fix worked for the file /includes/classes/seo.url.php too. Thanks for posting the fix.
-
Re: php 5.4 fatal error, query factory
I note the change
$sid = constant('SID');
has not been incorporated into 1.53 and the corresponding section in 1.6 has changed.
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
torvista
I note the change
$sid = constant('SID');
has not been incorporated into 1.53 and the corresponding section in 1.6 has changed.
... but only in the /admin/includes/functions/html_output.php; the store-side function does have the change incorporated.
-
Re: php 5.4 fatal error, query factory
Ah...jumped the gun again...I haven't got that far down the merge list yet!
-
Re: php 5.4 fatal error, query factory
Quote:
Originally Posted by
kagaroo
The problem was solved when I chose "$add_session_id=false" in both seo.url.php and html_output.php. The insteresting thing is that the freshly installed zc 1.51 could work even when "$add_session_id=true" was chosen.
Is there any problem if I chose "$add_session_id=false"?
This worked for me. I had been having issues with logging in for months. It kept throwing a 500 error. It only worked when you refreshed the page.