This is rather interesting, (as a figure of speech) because I am struggling with a similar problem with a perl/apache/COM setup. It goes like this:
Same thing is not reproducible from within the debugger so
some signal/event/threading model snafu appears to be responsible... what, exactly, beats me. And, how does one go about debugging such a problem?