This type of thing usually happens if the script dies unexpectedly before sending the headers. I'm not very familiar with Bugzilla, so I don't know what would necessarily be causing that. Because you mentioned it only happens occasionally, it will likely be a difficult problem to track down. Does Mozilla do any logging of its own? If so, you might want to turn it on and set it to the highest available level. If not, you may want to go through the code and print status messages to STDERR. Those will go to your error log.
And, of course, you might have better luck asking the Bugzilla people themselves. They might have encountered this problem before. Do they have a mailing list or discussion board (or Bugzilla Bugzilla :) )?