Error: Custom([file_write,stderr]) on startup

I recently released a game on Steam with openFL and HaxeFlixel and some users are reporting a crash on startup with the error “Error: Custom([file_write,stderr])”

I’ve seen the error myself in the past during development but it was very sporadic and haven’t seen it for a few months at least, and can’t reproduce it. It happens on the windows target. Maybe mac too but haven’t heard any reports yet.

Bug reports:
http://steamcommunity.com/app/368610/discussions/0/615086038664047518/
http://steamcommunity.com/app/368610/discussions/0/594820656463990356/

One user emailed me and says it happens just sometimes. Others all the time. Most people that buy the game seem to have no issues but there’s maybe 1% that get this error and can’t play at all.

I’m at a complete loss with very little to go on and can’t reproduce it, so I was hoping someone here may know what this error is about?

Thanks

I’ve seen similar errors myself, and I’ve been able to work them out based on context. Normally the error looks more like [file_open, C:\Example\Path\To\SomeFile.txt]. At first I thought it was a “this file is open in another program” error, but it’s more general than that. file_open is the name of the function that crashed, and SomeFile.txt was the file that it was trying to open.

So in your case, it’s the file_write function that’s crashing, and it’s crashing when it tries to write to stderr.

I don’t know what you could do about it, but hopefully this helps anyway.

Makes sense, and is also what I found in an old issue here:

FWIW the Custom([file_write,stderr]) is a message that appears when an exception is thrown and not caught. OpenFL then somehow tries to write that error to disk or something, but fails in the process and that dialog box appears. So, that means that any error that would throw an exception will give that same dialog box.

But unfortunately that still doesn’t help much, it still amounts to basically just “there was an error.”

I found one instance in openFL source of “stderr” at https://github.com/openfl/openfl/blob/1ea6f103a581f139821990470ba27a12884f1ab1/openfl/_legacy/Lib.hx
line 362, which seems where it likely comes from since there’s also a Sys.exit() immediately following.

It’s not just OpenFL that you have to search. OpenFL depends on Lime, and both of those depend on Haxe itself.

Plus, searching for “stderr” isn’t enough. You need to find where the file_write function is called.

Working backwards from there, we find that file_open() is only called from writeBytes(), which in turn is called from write(), which… is indeed called from rethrow().

Maybe you should make a couple changes to rethrow():

try {
    Sys.stderr ().write (Bytes.ofString (message));
} catch(e:haxe.io.Error) {
    throw new haxe.io.Error.Custom (message));
}

Hopefully then you can at least get the real error message.

This error occurs when trying to write a file, but it can’t – like trying to write to a file when the directory path has not been created. Could this be caused by using a SharedObject, or do you write a file somewhere in your code?

The only file writing being done would be with a SharedObject but I’m not sure if that would be the reason. Some users have fixed it after updating some sound drivers it seems, and others have it happen sporadically with different results depending on what other programs they have running. Nobody’s seem to found something that fixes it or makes it fail 100% of the time it seems. :confused: