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

OOM handling in C #10

Open
isaachier opened this issue Apr 16, 2018 · 0 comments
Open

OOM handling in C #10

isaachier opened this issue Apr 16, 2018 · 0 comments

Comments

@isaachier
Copy link

isaachier commented Apr 16, 2018

The h3 C library does not handle the case of malloc/calloc/realloc returning NULL in a robust manner. If assertions are enabled, the library crashes, otherwise it will use the NULL pointer leading to undefined behavior. While I understand the convenience of this design in the C library, not propagating OOM errors up the stack means binding code like this is not reliable:

jclass oome = (**env).FindClass(env, "java/lang/OutOfMemoryError");
Users are likely to see a sudden fatal crash in the Java process and may not see any hint to the C assertion. Practically, consider using return codes to handle OOM up the stack for your C functions so you can handle them probably here.

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

1 participant