You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Anybody using the setjmp/longjmp support in MPack? I'm going to remove it in 0.6 and replace it with an error callback and context.
The reason I'm removing it is because it's not safe to use in the straightforward way you would expect. The docs encourage putting a reader/writer/tree on the stack, but the contents of non-volatile stack variables that have changed after setjmp are undefined after the longjmp. To use it safely you'd have to declare the reader as volatile, or allocate it off the stack (and not change the pointer to it obviously.) Libraries like libpng that provide longjmp support wrap their structures so that they are allocated off the stack which is why they can offer this support safely.
I'll be retaining the non-local jump safety across MPack though, so from any error handler you'll still be able to longjmp or throw through MPack. An error callback will also make it easier to create C++ bindings which will have the option of throwing on error.
The text was updated successfully, but these errors were encountered:
Anybody using the setjmp/longjmp support in MPack? I'm going to remove it in 0.6 and replace it with an error callback and context.
The reason I'm removing it is because it's not safe to use in the straightforward way you would expect. The docs encourage putting a reader/writer/tree on the stack, but the contents of non-volatile stack variables that have changed after setjmp are undefined after the longjmp. To use it safely you'd have to declare the reader as volatile, or allocate it off the stack (and not change the pointer to it obviously.) Libraries like libpng that provide longjmp support wrap their structures so that they are allocated off the stack which is why they can offer this support safely.
I'll be retaining the non-local jump safety across MPack though, so from any error handler you'll still be able to longjmp or throw through MPack. An error callback will also make it easier to create C++ bindings which will have the option of throwing on error.
The text was updated successfully, but these errors were encountered: