Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling from within C #12

Open
gtamba opened this issue Jul 18, 2016 · 2 comments
Open

Error handling from within C #12

gtamba opened this issue Jul 18, 2016 · 2 comments

Comments

@gtamba
Copy link
Owner

gtamba commented Jul 18, 2016

As of now, any SPICE exception causes rb_raise() from within C to signal the error. This isn't a very good practice due to the call bypassing any memory cleanup code subsequent to the rb_raise() statement, as pointed out by Will Levine here.

SpiceRub uses NMatrix very frequently to represent Cartesian vectors and state/position arrays, so this could be a potential cause of memory problems in the future. I would like to switch to an error code system where the C function returns an error code which is parsed in Ruby as suggested in the above thread. There might possibly be a better way to this.

@gtamba
Copy link
Owner Author

gtamba commented Jul 18, 2016

As far as possible I have tried to call xfree() before checking if a SPICE Error has occurred.

@v0dro
Copy link

v0dro commented Jul 21, 2016

Good thought. I think we can use the design of your system in other Ruby gems using C extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants