Mono Fault Isolation

We have a Mono application on Linux that processes images in a bunch of files.

To do this, we (among other things) use System.Drawing, and for the most part this is good for us. Sometimes, however, we are confronted with an image that causes the application to crash - this is a failure in a normal call, and it is immune to capture attempts. Simplified, type call

System.Drawing.Image.FromFile(imagePath); 

will crash. The error message looks something like this:

 at (wrapper managed-to-native) System.Drawing.GDIPlus.GdipLoadImageFromFile (string,intptr&) <0xffffffff> 

It instantly pulls the entire application.

We came across several examples that this is happening - corrupted GIFs, unexpected headers in TIFF files - to name a few. Since we do not control the source of the images, we just have to deal with possible glitches.

Question:. I would like to highlight the places where we use GDI + (via System.Drawing) on ​​untrusted files so that it can successfully crash without killing the whole application.

I tried this using separate application domains, but I just can't stop the crashes. I'm probably doing it wrong!

<sub> Some details: openSUSE 11.4 (x86_64), Mono version 2.10.2, libgdiplus0 (package) 2.10-30.2, libtiff3 (package) 3.9.4-3.7.1 Sub>


Please note that the specific problems we experienced were quickly fixed - see comments below. The question still remains.

I would like to somehow isolate part of the program so that it does not pull it all out, but I am afraid that the only answer is to call an external process, as indicated in the answer below. I will leave it as it is for a while, and then I will accept this answer!

+4
source share
1 answer

Well, with a certain degree of naivety here, because I know little about Linux ... AppDomains (on Windows anyway) are in the same process. Try to separate the problematic code into another process using command lines or some communication mechanism, such as IPC, so that if it fails, it does not kill the main process, but only the child.

Although I have never had an excluded exception that caused my problems in the past, it seems like the main process has been killed, which is a layer below the AppDomain idea that you said you tried.

Translate to Linuxese where necessary ... sorry, I cannot be more specific.

0
source

All Articles