Forums / Bug Reports / [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

[Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

Locked

Views: 19,312

Results 21 to 40 of 40
This thread is locked. New replies are disabled.
18 Mar 2007, 6:35 PM
#21
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

[Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

"not server side" vs "worked fine before their upgrade" ... hmmm ... sounds like a classic "pass the buck" response...

Clearly something has changed. Finding out what is the key.
Maybe Zen Cart does have a bug. But, so far 30,000 others haven't encountered this one yet ...

EDIT: Correction. Perhaps someone else "has" encountered this.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Mar 2007, 6:52 PM
#22
jerkynet avatar

jerkynet

New Zenner

Join Date:
Nov 2006
Posts:
94
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

....pass the buck ....you got that right!

Your edit to html_header is in, not sure I see any difference in the debug....
http://www.jerkynet.com/demo137/store

18 Mar 2007, 7:14 PM
#23
jerkynet avatar

jerkynet

New Zenner

Join Date:
Nov 2006
Posts:
94
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

More comments from the hosting co.

I'm afraid we can't troubleshoot this issue for you any further on a server level. It appears quite clearly that this is related to PHP 5.2.1 and its interaction with the get_template_part() function in template_func.php. $file_extension = '.php' is not being passed or read properly as it always reads .php, regardless if .css is passed to the function. If you change that to $file_extension = '.css' your stylesheets load properly; of course this overwrites any .php extensions being passed into the function and other areas of the site break. There is some sort of oddity with that variable and PHP5.2.1. I can't really say what as I'm not a developer and as I'm sure you can understand, it's outside the scope of IPS support to troubleshoot third party scripts.

As indicated, no other server changes have been made except an upgrade to PHP5.

I think our team have done an outstanding job of helping to troubleshoot this issue for you, to the point of downloading the software ourselves, however, I'm afraid there's little more to do without further information that's not related to permissions. As said, if you override the aforementioned variable, the stylesheet function works perfectly. That should be his/her starting point for further diagnosis.

18 Mar 2007, 7:54 PM
#24
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

You can remove the local/configure.php file ... I'm pretty sure it's not helping us any right now.

I'm really puzzled about why it's not showing any files now ...

It's suggesting a server problem or limitation. If it's a Zen Cart bug, it's an obscure one.

very odd

still trying to figure out why their directory listings don't bring back results ...

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Mar 2007, 8:52 PM
#25
jerkynet avatar

jerkynet

New Zenner

Join Date:
Nov 2006
Posts:
94
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

kowning this crew, they may have thrown/not thrown a needed switch in the apache side, during compile?
Just thinking out loud.....

I used to trust these guys........now I find myself thinking of all the bonehead mistakes they could have made.

Thier primary buss is a php based msg. board, so not necessarily meaning the NOC boys are php savy, but I did check on a couple of thier boards running on this box, and they are all fine, use css as well........

?
Dave

18 Mar 2007, 8:53 PM
#26
jerkynet avatar

jerkynet

New Zenner

Join Date:
Nov 2006
Posts:
94
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

keying in on one sentence of his reply.....

get_template_part() function in template_func.php. $file_extension = '.php' is not being passed or read properly as it always reads .php, regardless if .css is passed to the function. If you change that to $file_extension = '.css' your stylesheets load properly;

18 Mar 2007, 9:10 PM
#27
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

I took their "test.php" and copied it to the demo area for safer testing away from your main store.

It works fine on its own.
http://jerkynet.com/demo137/store/test.php

But when doing the same thing inside the html_header.php, it fails to bring back any results ...

This suggests that some "otherwise normal" setting seems to be busting the results found.
http://jerkynet.com/demo137/store/index.php

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Mar 2007, 9:26 PM
#28
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

jerkynet:

keying in on one sentence of his reply.....

get_template_part() function in template_func.php. $file_extension = '.php' is not being passed or read properly as it always reads .php, regardless if .css is passed to the function. If you change that to $file_extension = '.css' your stylesheets load properly;

To test that theory, I created stylesheet.php and changed the call from .css to .php ... and it still fails.

Odd...

It works fine when it's not being called via Zen Cart, but fails while running from within Zen Cart.
Which of course is why they'd point the finger at Zen Cart ...

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Mar 2007, 9:37 PM
#29
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

jerkynet:

More comments from the hosting co.

If you change that to $file_extension = '.css' your stylesheets load properly
Actually, this is not true. Just tried it. Still fails. And of course so does everything else.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Mar 2007, 10:04 PM
#30
jerkynet avatar

jerkynet

New Zenner

Join Date:
Nov 2006
Posts:
94
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

hosting guy just chimed in.........

Hello,

I didn't notice exactly the same thing as Lindy, but the problem I seen was in the same function.

The get_template_part code does this:

if ($dir = @dir($page_directory)) {
while ($file = $dir->read()) {
if (!is_dir($page_directory . $file)) {
if (substr($file, strrpos($file, '.')) == $file_extension && preg_match($template_part, $file)) {
$directory_array[] = $file;
}
}
}

This is what doesn't appear to work correctly, the while loop is never run, there is never anything in $file.

I copied basically the same code outside of Zen and tested it.
The code is here: http://jerkynet.com/store/test.phps
The results are: http://jerkynet.com/store/test.php

The test code is almost identical to that function, and yet the code internal to Zen Cart doesn't work.

This is why it looks like Zen is at fault, something happening before or after this function appears to be corrupting the results, or the parameters passed to the function are not correct,

Thanks,

Stewart

18 Mar 2007, 10:11 PM
#31
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

that's the same as I was saying earlier

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Mar 2007, 5:43 AM
#32
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

Seems to be a threshold limit on the number of open "dir" listings done during page load. That would explain why if it's only called once from a test.php script that the problem wouldn't manifest ...

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Mar 2007, 7:00 AM
#33
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

Eureka !

Okay ... two things ...

  1. Your hosting server has a limitation on the number of open file/dir handles that can be active at a given point in time -- at least at the per-session level.

The setting currently in place on your hosting server is lower than any other server running Zen Cart today.

  1. Having the setting so low has exposed a bug in Zen Cart. There are a couple places in the code where directory handles are used but not closed when we're finished with them. :blush:

As such, they were remaining open and maxing out. Then, when it came time to look up your css folder contents, it failed because there were no handles left for that session to use.

I've already uploaded the corrected files to your demo area and your live site, which is functioning properly now.
I've also attached the fixed files here for your convenience.
The fix will be included in the v1.3.8 release when it comes out.

Thanks for your patience in sorting out this problem. While your hosting company isn't entirely to blame, it would be prudent for them to raise the limit of open handles so that similar such errors (which, admittedly, are just sloppy coding <grimace>) don't shut down other shops/sites who may come along in the future.***

EDIT: Please use the attachment located at:
http://www.zen-cart.com/forum/showpost.php?p=345929

This is fixed in v1.3.8. This patch is intended ONLY for v1.3.7.***

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Mar 2007, 4:29 PM
#34
jerkynet avatar

jerkynet

New Zenner

Join Date:
Nov 2006
Posts:
94
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

DrByte....

Thankyou very much for your attention to this problem. Passed along your comments this am to the idiots at the no-support-DC....and of course, thier answer was as expected.........."Glad we found our problem...."

Will be packing up and getting out of this DC over the next week-two.

Thanks again!
Dave

19 Mar 2007, 4:50 PM
#35
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,684
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

OT- but you REALLY - REALLY need to optimize your images - no one is going to wait for that page to load -

http://www.websiteoptimization.com/services/analyze/wso.php?url=http://jerkynet.com/store/

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

19 Mar 2007, 5:35 PM
#36
birdoasis avatar

birdoasis

Inactive

Join Date:
Jun 2005
Location:
Cheney WA
Posts:
1,123
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

Sounds like DR. Byte gets some free jerkey!

We need to keep his energy up.

I'm trying to convince my wife that jerkey is good for me. It helps people like me with A.D.D. to think on the run. hehe.

Chewing alone has been found to increase brain activity and help when taking test and studying.

A jerkey that isn't chewy is just sauce.

John Patrick
A Zen Cart Advocate!

20 Mar 2007, 8:44 AM
#37
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

Summary:
There are a couple places in the code where directory handles are used but not closed when we're finished with them. (A couple on the catalog side, and several on the admin side).

The impact of this bug is that they were remaining open and maxing out when the server is configured with lower-than-usual available-memory settings. Then, when it came time to look up your css folder contents, it failed because there were no handles left for that session to use.

This set of files both the catalog and admin side with respect to directory handles being released when finished them.

*This issue affects v1.3.0 thru v1.3.7.
*This patch can be applied to v1.3.6 and v1.3.7. **
These fixes will be included from v1.3.8 and newer.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

20 Mar 2007, 12:02 PM
#38
adds avatar

adds

Zen Follower

Join Date:
Nov 2005
Posts:
255
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

Hi,
Can I just say i like the look of your template, can I ask where you purchased it from?

20 Mar 2007, 5:09 PM
#39
jerkynet avatar

jerkynet

New Zenner

Join Date:
Nov 2006
Posts:
94
Plugin Contributions:
0

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

Adds...

Thanks! I hacked it together on my own.....
Dave

5 Jun 2007, 5:42 AM
#40
maxrisc avatar

maxrisc

Zen Follower

Join Date:
Mar 2007
Location:
Houston
Posts:
246
Plugin Contributions:
1

Re: [Done v1.3.8] dir handles not closed, causes memory leak and won't load stylesheet

Same problem. Instead of increasing the file handles I took the easy route.

ZenCart 1.3.7 / PHP 5.0.4

Thank you for the patch. :D

David

Auction Lister Pro
The Zen Way To Ebay

Support Forum