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

CAMLlocal bug in stubs #1

Merged
merged 1 commit into from
Aug 9, 2016
Merged

CAMLlocal bug in stubs #1

merged 1 commit into from
Aug 9, 2016

Conversation

damiendoligez
Copy link
Contributor

You cannot use the CAMLlocal* macros without an enclosing CAMLparam*, otherwise you end up accessing a piece of the stack that was deallocated (and potentially reused). OCaml 4.04.0 guards against this mistake.

Since there is no allocation between the initialization of ans and the return, you don't need the call to CAMLlocal1.

You cannot use the `CAMLlocal*` macros without an enclosing `CAMLparam*`, otherwise you end up accessing a piece of the stack that was deallocated (and potentially reused). OCaml 4.04.0 guards against this mistake.

Since there is no allocation between the initialization of `ans` and the `return`, you don't need the call to `CAMLlocal1`.
@toots
Copy link
Member

toots commented Aug 9, 2016

Makes sense, thanks!

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

Successfully merging this pull request may close these issues.

2 participants