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

Fix illegal read in fill_window_dups_rev #264

Merged

Conversation

TomAndrews
Copy link
Contributor

I'm not 100% sure this is the appropriate fix but it seems to fix my example.

'Writing R Extensions' says:

Protection is not needed for objects which R already knows are in use. In particular, this
applies to function arguments.

Which makes me think that the original code should be fine, but it also says:

in general we do not know (nor want to know) what is hiding behind the
R macros and functions we use, and any of them might cause memory to be allocated, hence
garbage collection and hence our object ab to be removed. It is usually wise to err on the side
of caution and assume that any of the R macros and functions might remove the object.

Could lengthgets be triggering the garbage collection and deleting the unprotected _out even though it's a function argument?

Without the PROTECT you get an illegal read which sometimes causes a
segfault.

Fixes joshuaulrich#263.
@joshuaulrich
Copy link
Owner

This looks good to me. This was a really silly error on my part. Of course lengthgets() allocates. It lengthens/shortens a vector. That means _out is available for GC.

I don't think _trunc needs protection, since it's immediately returned. But it's not going to hurt anything either.

@joshuaulrich joshuaulrich merged commit e3120c6 into joshuaulrich:master Aug 15, 2018
@joshuaulrich joshuaulrich added this to the Release 0.11-1 milestone Aug 19, 2018
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.

None yet

2 participants