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
merged 1 commit into from Aug 15, 2018

Conversation

Projects
None yet
2 participants
@TomAndrews
Contributor

TomAndrews commented Aug 15, 2018

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?

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

Fixes #263.
@joshuaulrich

This comment has been minimized.

Show comment
Hide comment
@joshuaulrich

joshuaulrich Aug 15, 2018

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.

Owner

joshuaulrich commented Aug 15, 2018

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@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