Hi All
I have had the exit() calls in Plplot rolling around in the back of my head for 
a while. They were brought to the fore, recently when I had some code which 
generated a lot of plots and displayed them all via wxWidgets - except it 
didn't. The program exited half way through. It turned out that I ran out of 
memory and this caused a call to plexit which exited my code without even an 
unhandled exception error, which is what I usually expect with out of memory 
problems. Also the move to git has got me excited about doing some work.

Obviously the API functions do not return an error code, but we do have the 
plserror function which allows us to report errors back to the user. The 
difficulty however is more internal. If the program runs out of memory, but we 
allow things to continue, then when attempts are made to access the array then 
we'll get a segfault or similar crash.

As far as I can see we have two solutions:
1) Change all internal functions so they return an error code. If another 
internal function finds it is passed an error code then in must clean up and 
return this error code - which passes down the chain. This sounds quite 
difficult as some functions already return values. Also if an internal function 
calls an API function we break the chain.
2) Add an internalerrorcode variable to PLStream. This is reset to 0 when an 
API call is made, and if a function generates an error then this code and the 
user's code) get set and the calling function can check this. The downside here 
is probably a lot of error checking, but I don't think this can be helped.

I'm in favour of 2), mostly because I haven't thought of any killer problems 
like 1). Has anyone got any thoughts before I start working on this?

Phil
------------------------------------------------------------------------------
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to