Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
OT: Heisenbug with binary data output in PHP
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Felix Geisendörfer  
View profile  
 More options Nov 1 2006, 9:24 am
From: Felix Geisendörfer <haimu...@gmail.com>
Date: Wed, 01 Nov 2006 15:24:01 +0100
Local: Wed, Nov 1 2006 9:24 am
Subject: OT: Heisenbug with binary data output in PHP

  Hi,

first of all, this problem has been stopping me from making any progress
with my CakePHP application for 2 days by now, but as far as I can tell
it's a general PHP problem (means it occurs in a standalone script as
well). However, since I know there are some very smart & experienced php
folks on this group I hope somebody might be able to help me out on this
one anyway. (I also suspect the issue is not related to my code but to
my local setup).

So the problem is the following: I want to use a Controller to serve jpg
images stored outside the webroot folder to the visitors of the site I'm
working on. Essentially I just want to use PHP to output the contents of
a file to the browser. This should be the easiest thing in the world,
but I'm experiencing a Heisenbug
<http://en.wikipedia.org/wiki/Heisenbug> where in some cases not the
entire image is displayed but rather only the top part of it and the
rest is either left blank or (partially) covered with random patterns
(like when a DivX encoded video turns bad and some frames have lot's of
green or such in them). This happens with all pictures I use, even so if
I put those images in the webroot they display just fine. And as I said,
sometimes (25-33%) the bug does not occur at all and there is no problem
(therefor I call it a Heisenbug).

The code I use looks like this:
--------------------------------------------------------------------------- -----------------------------
$pictureFile = Picture::getPath($picture);      
$fileSize    = filesize($pictureFile);

header('Content-Type: image/jpeg');
header('Content-Length: '.$fileSize);

$fp = fopen($pictureFile, 'rb');
fpassthru($fp);
fclose($fp);
--------------------------------------------------------------------------- -----------------------------

Now I tried various things to fix this. I used a loop to output the
image. I used readfile. I used echo file_get_contents(), I used
ob_flush() and flush() but nothing seemed to have any effect. One thing
that seemed to slightly decrease the problem (more of the image get's
displayed) was to put usleep() function calls inside a loop that's echo
& fread'ing the picture. Adding an echo "Hello"; statement at the end of
the function and turning off the image/jpeg header (and thus looking at
the raw output) unveiled that the problem is definitely caused by parts
of the output getting lost. Because the length of the output varied and
most of the times the "Hello" at then end was missing.

Being on the edge of going insane I also uploaded the script to my web
host to see if this behavior would also exist on other platforms - it
does not! So chances are there is something wrong with my local setup,
and the php code is just fine. Here is what I'm currently running on:

Windows XP - no service pack (got a legitimate copy, but their patches
seem to be incompatible with my hardware ...)
PHP 4.4.1 (that's what runs on my web host, I just updated to it from
4.4.0 to make sure the bug is not due to my old version)
Apache 2.0.55

I already checked douzens of php.ini options related to output
buffering, memory limits, and such things, but no success. Oh and
another very important point is that my script executes completely, even
if output get's lost. I checked this by saving the contents of the image
file into a variable, dumping the variable content and then saving it to
a new file. The resulting image file displayed just fine, the dumped
variable content produced the Heisenbug that gives me headaches ...

Alright, I'm close to either killing myself or to reconfigure my entire
development environment, so if anybody has the slightest idea what could
be going on here, please let me know. The last days have been bad
already since one of my SVN repositories went bad (and was
unrecoverable) and now this ... Time for a vacation I guess ... : /.

And again, sorry for this being off topic but I'm pretty desperate.
Felix Geisendörfer aka the_undefined
--
--------------------------
http://www.thinkingphp.org
http://www.fg-webdesign.de


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dr. Tarique Sani <tarique@sanisoft.com>  
View profile  
 More options Nov 2 2006, 11:22 pm
From: "Dr. Tarique Sani <tari...@sanisoft.com>" <wekn...@gmail.com>
Date: Fri, 03 Nov 2006 04:22:07 -0000
Local: Thurs, Nov 2 2006 11:22 pm
Subject: Re: OT: Heisenbug with binary data output in PHP
Can you give the URL of the offending image? I will try and look into
it

Cheers
Tarique


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix Geisendörfer  
View profile  
 More options Nov 3 2006, 1:29 am
From: Felix Geisendörfer <haimu...@gmail.com>
Date: Fri, 03 Nov 2006 07:29:48 +0100
Local: Fri, Nov 3 2006 1:29 am
Subject: Re: OT: Heisenbug with binary data output in PHP

Hi,

http://www.thinkingphp.org/133.jpg would be a direct link to one of the
images I test with, however all pictures I tried behave the same way.
http://www.thinkingphp.org/image.php (source can be found at
http://www.thinkingphp.org/image.phps) would be a script that runs fine
on my host (serving 133.jpg), but causes the Heisenbug on my system.

Thanks for your interest!

Felix
--------------------------
http://www.thinkingphp.org
http://www.fg-webdesign.de

Dr. Tarique Sani <tari...@sanisoft.com> schrieb:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bert Van den Brande  
View profile  
 More options Nov 3 2006, 1:37 am
From: "Bert Van den Brande" <cyr...@gmail.com>
Date: Fri, 3 Nov 2006 07:37:22 +0100
Local: Fri, Nov 3 2006 1:37 am
Subject: Re: OT: Heisenbug with binary data output in PHP
Did you try it with different browsers ?

Since it works fine on you webhost I'm guessing this is a weird
windows related problem, so those service packs might not be a bad
idea ...

Do you have a virus scanner or something ? Maybe the scanner has
problems with Apache or Php ...

This is by far one of the weirdest php-related problems I've heard of :)

On 11/3/06, Dr. Tarique Sani <tari...@sanisoft.com> <wekn...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix Geisendörfer  
View profile  
 More options Nov 3 2006, 2:50 am
From: Felix Geisendörfer <haimu...@gmail.com>
Date: Fri, 03 Nov 2006 08:50:35 +0100
Local: Fri, Nov 3 2006 2:50 am
Subject: Re: OT: Heisenbug with binary data output in PHP

  Hi Bert,

I can't get the service packs, they are incompatible with my hardware. I
spent 12 hours at a LAN party once trying to get them on my machine and
besides loosing data, cursing a lot and seeing more blue screens of
death then I thought WinXP to have I decided to not ever try this again.

I tried it with different browser (FF 1.5, IE 6, Opera 9) and they all
show the same / similar behavior.

Turning of my virus scanner is something I haven't tried yet. I'll do
that together with the firewall, but I can't see why either one of them
would randomly swallow the last packages of pictures provided via php
... I'll let you know what happens.

Best Regards,
Felix Geisendörfer
--------------------------
http://www.thinkingphp.org
http://www.fg-webdesign.de

Bert Van den Brande schrieb:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bert Van den Brande  
View profile  
 More options Nov 3 2006, 3:05 am
From: "Bert Van den Brande" <cyr...@gmail.com>
Date: Fri, 3 Nov 2006 09:05:33 +0100
Local: Fri, Nov 3 2006 3:05 am
Subject: Re: OT: Heisenbug with binary data output in PHP
Have you tried reading the image with a buffer in php ?

On 11/3/06, Felix Geisendörfer <haimu...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gustavo Carreno  
View profile  
 More options Nov 3 2006, 3:54 am
From: "Gustavo Carreno" <gcarreno...@gmail.com>
Date: Fri, 3 Nov 2006 08:54:26 +0000
Local: Fri, Nov 3 2006 3:54 am
Subject: Re: OT: Heisenbug with binary data output in PHP
Hey Felix,

Just remembered something, have you tryed with the GD functions yet?
I know it could a bit more work since you are not doing any image
manipulation, but could you try and use ImageJPG/GIF/PNG to output
your images, just to exclude a general output problem and focusing on
the fread, fpassthru problem ?

--
Gustavo Carreno
---
< If you know Red Hat you know Red Hat,
If you know Slackware you know Linux >


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
meek  
View profile  
 More options Nov 3 2006, 4:48 am
From: "meek" <robert.m...@gmail.com>
Date: Fri, 03 Nov 2006 01:48:33 -0800
Local: Fri, Nov 3 2006 4:48 am
Subject: Re: OT: Heisenbug with binary data output in PHP
Hi Felix,
Maybe you could post your php.ini and httpd.conf.
My development setup is very similar to yours and I can't reproduce the
problem with your script and image.
Couldn't have anything to do with your WLAN .jpg hack could it?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
meek  
View profile  
 More options Nov 3 2006, 4:53 am
From: "meek" <robert.m...@gmail.com>
Date: Fri, 03 Nov 2006 09:53:38 -0000
Local: Fri, Nov 3 2006 4:53 am
Subject: Re: OT: Heisenbug with binary data output in PHP
Also maybe a screenshot of what you get - and do you have the same
problem with other filetypes like a .png for example?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
meek  
View profile  
 More options Nov 3 2006, 5:01 am
From: "meek" <robert.m...@gmail.com>
Date: Fri, 03 Nov 2006 10:01:24 -0000
Local: Fri, Nov 3 2006 5:01 am
Subject: Re: OT: Heisenbug with binary data output in PHP
I found a couple of things which might be relevant:

The section 'Problems Installing or Running Apache 2' on this page:

http://www.apache.org/dist/httpd/binaries/win32/README.html

- which I got to from this:

http://marc2.theaimsgroup.com/?l=apache-bugdb&m=101484400413021&w=2


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix Geisendörfer  
View profile  
 More options Nov 3 2006, 7:05 am
From: Felix Geisendörfer <haimu...@gmail.com>
Date: Fri, 03 Nov 2006 13:05:38 +0100
Local: Fri, Nov 3 2006 7:05 am
Subject: Re: OT: Heisenbug with binary data output in PHP

Hey meek,

I think you found the exact bug. It's Microsoft to blame:
http://support.microsoft.com/default.aspx?scid=kb;en-us;317949

>     SYMPTOMS

> Data loss may occur if all of the following conditions exist:

>     * A bind of a listen socket is completed in a parent process.
>     * An accept is completed in a child process.
>     * Fast sends are happening.

This is exactly what I experience, and this explains why putting some
usleep() statements in when outputting the image via a fread loop seems
to have a positive effect (slows down the send process)!

However, I'm not sure if I like the solution:

>     RESOLUTION

> To resolve this problem, obtain the latest service pack for Windows
> XP. For additional information, click the following article number to
> view the article in the Microsoft Knowledge Base:

The problem is that I have had a really bad time installing a service
pack on my system in the past, but maybe that was because I tried to
install from a different windows cd (I got an OEM version) with SP 2
instead of Downloading the patch (which is a bad option since I'm on 64
kbit) ...

Hmm but they a /Afd.sys/ file that seems to be problematic, maybe I can
simply replace this with a SP 2 version. (Yeah, I know it's a bad idea ^^).

Thanks to all the others who have looked into this as well. I'll see if
I can fix my system somehow without going through some major pain ...

--Felix Geisendörfer aka the_undefined
--------------------------
http://www.thinkingphp.org
http://www.fg-webdesign.de

meek schrieb:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bert Van den Brande  
View profile  
 More options Nov 3 2006, 7:09 am
From: "Bert Van den Brande" <cyr...@gmail.com>
Date: Fri, 3 Nov 2006 13:09:34 +0100
Local: Fri, Nov 3 2006 7:09 am
Subject: Re: OT: Heisenbug with binary data output in PHP
Good to know, seems our educated guess that this was a Windows problem
was completely correct :)

On 11/3/06, Felix Geisendörfer <haimu...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix Geisendörfer  
View profile  
 More options Nov 3 2006, 8:57 am
From: Felix Geisendörfer <haimu...@gmail.com>
Date: Fri, 03 Nov 2006 14:57:35 +0100
Local: Fri, Nov 3 2006 8:57 am
Subject: Re: OT: Heisenbug with binary data output in PHP

Ok, I resolved the issue by replacing my afd.sys with a newer version I
got from a friend via email. Big thanks to everybody who has looked into
the issue, especially meek!

In order to save others from having this nightmare in future I did a
little blog post
<http://www.thinkingphp.org/2006/11/03/windows-xp-apache-php-output-pr...>
that describes the symptoms I had together with the solution that helped me.

--Felix Geisendörfer aka the_undefined
--------------------------
http://www.thinkingphp.org
http://www.fg-webdesign.de

Bert Van den Brande schrieb:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »