So, I could use some help. This is in the theory that explaining
the bug I see often helps you find it…

The web hosters claim the wrapper script is fine. Okay, lets say it is. So
it’s something wrong with my script right?

the script is called “showImage.py”. It’s a get, it expects querystring
of the form “image=something.jpg”


For almost all cases, calling the cgi works fine. Except, with a couple
of images, it gives an internal server error. Okay, first thought, there
is something wrong with those images, probabaly a perms problem…
Nope, perms are fine. Maybe the database entry is incorrect? Nope,
looks fine.

So I scratch my head for a while and then decide to start debuging
the scipt heavily, so I `cp showImage.py showImage2.py”. And
I go and run showImage2.py and shazamm, it works. Blink.
So I look at the files again, they are identical. md5sums are
the same. Then I try `ln -s showImage.py showImage3.py`.
showImage3.py works as well.

Oh, and to make it more fun. Remember that showImage.py
only fails on some images. Now, showImage4.py and
showImage2.py fail on other files, but showImage11.py
works on those, fails on others.

I should reiterate these are all symlinks to the same
script.

Now, to make it more fun. All of these scripts do
the right thing when invoked from the commandline
with the approriate env variables set to pass the
querystring. Looking at the cgi module, there shouldnt
really be any difference there.

Did I mention this all worked fine on the last hoster who was
using suexec and on wilber.gimp.org with out suexec or cgiwrap.

Oh, and when the script fails, nothing gets log. No python
tracebacks (which go to stderr). If I instrument the script to
write to stderr at the very begining of the script, nothing
gets logged. It’s almost as if the wrapper script is never
running the script at all.

Everything I look at scriptwise looks okay.

But, if I replace say, showImage4.py with a bash script that
just echos a content type and some garbage, it’s fine.

So somehow, it sems like the combo of the length of the
script name and the length of the arguments breaks the
script (or the wrapper). The scripts work fine when given
these arguments at the commandline. In particular, any
time the length of these is “35” chars or “51” chars.
What the fuck is up with that?

*boggle*

At no point does any of my code look for argv[0] or
anything like that. cgi.py does a bit, so thats where
I’m concentrating now. Annoying.