debuggable

 
Contact Us
 

Being trapped in programmers hell

Posted on 2/11/06 by Felix Geisendörfer

Deprecated post

The authors of this post have marked it as deprecated. This means the information displayed is most likely outdated, inaccurate, boring or a combination of all three.

Policy: We never delete deprecated posts, but they are not listed in our categories or show up in the search anymore.

Comments: You can continue to leave comments on this post, but please consult Google or our search first if you want to get an answer ; ).

Yeah, that's how I feel right now, like I'm in hell. Well, minus meeting all the interesting people that supposely went there for the even more interesting things they did in their lives.

What's the matter? I don't know. On Saturday I wanted to commit some changes to one of my local SVN repositories and got some ugly "couldn't establish ra_local_session" error message from TortoiseSVN, and that's when all the trouble started ... Before that I was just enjoying an amazing productivity high, created by the numerous changes I've recently tried to make in my life and felt like writing a little post about this. Right now, 5 days laters, I can hardly remember how it felt to be productive.

The entire SVN problem turned out to be a nightmare. I could find some people having the same issue via google, but all of them had the problem when doing any svn operation. I only had the issue with commit - update, info, export, etc. worked just fine. And of course, none of the solutions I found seemed to be related or helping in my case. I tried to use the svn admin tools to repair my (corrupted?) svn repository, but no luck. I spent hours and hours trouble shooting, but nothing helped. Finally I thought maybe updating to svn 1.4 would solve my problem, but far from it. To make a long story short, TortoiseSVN 1.4 broke my shell integration, did not fix the issue and caused nothing but trouble.

So that's how I spent my Saturday and Sunday. I finally gave up and started the repository all over again. Luckily this had been a young project with no important branches yet. But still, I really really hate not being able to solve a problem, it's not a good sign.

Monday came. I wanted to continue working on my big CMS project that was scheduled for a presentation with the client tonight, and things seemed to look good. I was integrating a PicturesController for image uploads (including zipped files with numerous images) and I was very confident to meet the deadline. Let's put it like that, since the late afternoon of Monday, I've been writing about ~5 lines of productive code for that project, and no I was not able to make the deadline working.

Once again, hell broke loose and something as ridicolous easy as readfile(); failed on me. If you want to get detailed information on my issue, checkout this post on the Google Group. Or to make this a short story as well: I have to serve an image via CakePHP but it only partially get's to the browser. And even worse: It's a Heisenbug in the sense that in some cases the picture get's displayed completely, and in all the other cases only in fragments and apparantly some code I tried had a small effect on the amount of bytes that make it to the browser. So I've spent hours and hours researching this, stumbling across some people having the same issue with various php/apache setups, but no solution. Right now I've tried just about anything from paranoid ob_flushing, sending different header data, testing across multiple browser, php.ini/httpd.conf tweaking, numerous reboots and even more numerous apache restarts, updating php, updating apache, switching from FastCGI to running php as a module to banging my head against the monitor and more. All of this brought no solution to my problem. In the best cases nothing happened, but usally more problems arose which turned out to be even harder to fix. The best one being CakePHP not running when setting up php as an apache module ...

Those of you who have read my google group post might think I'm stupid for not just ignoring the issue as it does not occur with my host, but to me there is no way to move on before fixing my problem. I cannot accept working with a dev system that shows incosistent output behavior, that's suicide. But if I can't fix this problem at some point soon, I can't guarantee for my surrival either. It's a nightmare, it's hell ...

So why have I bothered to write this post? Well maybe to relief the pain a little bit, maybe to join Jonathan Snook having a bad time, or maybe simply to let you guys know I'm not dead (yet) and new posts will come as soon as I go back to being a php developer rather then a windows victim.

In any case, wish me luck and if you have the slightest idea what could fix my issue, please let me know!

--Felix Geisendörfer aka the_undefined

 

You can skip to the end and add a comment.

Ben  said on Nov 02, 2006:

Is it particular images that set it off?

By this I mean, does one image always cause the problem while other may never have it?

It could be an issue with the files you're trying to serve rather than the PHP code.

I would also ask why you're using fpassthru(). If you're just reading the file straight out to the browser, you should try readfile(). It'll save mucking about with the fopen/fclose calls and may not trigger your problem.

Actually, after looking it up, the PHP manual suggests the above approach if you don't need to seek within the file.

Felix Geisendörfer said on Nov 02, 2006:

Ben: The problem exists when using readfile, fpassthru, fread (in a loop) and any other way to output the data. This is regardless of the picture. Now even more odd: If I capture the output to a variable and echo the contents of this variable and then save the variable contents to a file then the image in the browser has the bug, but the on saved to the disk does not ... It's insane ...

Gabriel said on Nov 02, 2006:

But still, I really really hate not being able to solve a problem, it’s not a good sign.[...]but to me there is no way to move on before fixing my problem

This really is the hardest part! I think I can feel for you and your situation; a few weeks ago I had a problem the other way around: on my WinXP development machine everything worked like a charm, and on the linux production server the problem appeared: the image crop function of ImageMagic did not work like expected (white stripes on both sides). After way too much research I hacked together a solution "around" the bug, that only affected the server version of IM and only using GIF images.

and no I was not able to make the deadline working.

Maybe the saying of Douglas Adams can help you keeping the faith nevertheless: "I love deadlines. I specially love the swooshing sound they make as they fly by."

Hang in there!
Gabriel

Ben  said on Nov 02, 2006:

So basically there's no way to reproduce/not produce the bug on demand?

That's always right pain. I wish you luck in tracking it down.

Tarique Sani said on Nov 03, 2006:

If bug is independent of the image used try and see if it is independent of the machine / PHP version used....

Felix Geisendörfer said on Nov 03, 2006:

Thanks for the comments. Ben: No, I could not give somebody instructions on how to reproduce the bug, I have not idea what is actually causing it. However, I have a strong suspision it could be related to runninng PHP as FastCGI, but running PHP as an apache module has brought it's own (similiary hairy) issues.

Tarique: No it's not machine independent. The script runs just fine on my host. I use php 4.4.1, the same version as my host, and apache 2.0.59. I will probably try php 4.4.4 today, but upgrading from 4.4.0->4.4.1 yesterday didn't change anything, and my host runs the same php version without problems. The thing is simply: I need the code to run on my dev box, I cannot switch systems : /. And I have to stick with Apache 2.x and I also would like to run the same php version as my host does ...

Dieter@be  said on Nov 03, 2006:

well i know that on linux many problems are caused by the different threading options that apache supports
on my distribution (gentoo) php is only supported when using the mpm-prefork engine. mpm-worker has some known issues. Not using any MPM at all is also an option, but i would first try preforking.

And speaking about the programmers hell: tell me about it!
my phpeclipse IDE has been crashing all the time, productivity dropped quite a lot, so join the club

[...] Oh boy, this has been a true nightmare and I really want to thank all the people who have thrown in their suggestions in the Google Group post and the blog post I made. Now I can finally go back to being productive! [...]

Jim  said on Nov 13, 2006:

I had a similar run in with attempting to display images via CakePHP earlier last week. My problem was no where near the severity of yours (as it turns out). I also missed my deadline because of this (thought, it wasn't necessarily a rock solid one). It ended up that I was outputting some extra white space in my image data, at the top of the browser. Once I noticed it, it was just a matter of finding the right file.

Did you get your issue fixed? What was involved?

Felix Geisendörfer said on Nov 17, 2006:

Hey Jim: Checkout this post here, http://www.thinkingphp.org/2006/11/03/windows-xp-apache-php-output-problem/.

This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.