-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Segfault on invalid group_by_ and mutate_impl #1750
Labels
bug
an unexpected problem or unintended behavior
Comments
I would not expect this to work as the expression you are > lazyeval::interp(~ntile(sortvar, n_groups), .values = list(sortvar=sortvar, n_groups=n_groups))
~ntile("Sepal.Length", 3) See the quotes there. This however works: > iris2 <- group_by_(iris, .dots = lazyeval::interp(~ntile(sortvar, n_groups), .values = list(sortvar=as.name(sortvar), n_groups=n_groups)))
> iris2
Source: local data frame [150 x 6]
Groups: ntile(Sepal.Length, 3) [3]
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
<dbl> <dbl> <dbl> <dbl> <fctr>
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
6 5.4 3.9 1.7 0.4 setosa
7 4.6 3.4 1.4 0.3 setosa
8 5.0 3.4 1.5 0.2 setosa
9 4.4 2.9 1.4 0.2 setosa
10 4.9 3.1 1.5 0.1 setosa
.. ... ... ... ... ...
Variables not shown: ntile(Sepal.Length, 3) <int>. See the |
So the problem becomes: > iris %>% mutate( a = ntile("Sepal.Length", 3 ) )
Error in mutate_impl(.data, dots) :
CHAR() can only be applied to a 'CHARSXP', not a 'list' |
sicarul
pushed a commit
to sicarul/dplyr
that referenced
this issue
May 4, 2016
as the number of rows of the data to process, fall back to R eval otherwise. This deals with the segfault reported in tidyverse#1750. closes tidyverse#1750
sicarul
pushed a commit
to sicarul/dplyr
that referenced
this issue
May 4, 2016
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Debugging on some
group_by_
code, I found I could generate a segfault with these three lines:(Sometimes the last line has to be run multiple times to segfault, but I can consistently generate a crash with fewer than six attempts.)
It's also interesting that the error from the
group_by_
call is not consistent (in the cases where R doesn't segfault). The message seems to alternate between:CHAR() can only be applied to a 'CHARSXP', not a 'logical'
CHAR() can only be applied to a 'CHARSXP', not a 'closure'
CHAR() can only be applied to a 'CHARSXP', not a 'integer'
CHAR() can only be applied to a 'CHARSXP', not a 'character'
CHAR() can only be applied to a 'CHARSXP', not a 'NULL'
Here's the segfault traceback:
The issue is the same for the CRAN and development versions of dplyr (versions 0.4.3 and 0.4.3.9001). Here's my sessionInfo (with the development versions of dplyr and lazyeval):
Possibly related: #1668, #1641.
This is not urgent! Obviously, fixing edge cases where users are writing buggy code shouldn't be a priority, but segfaults are always a little disconcerting.
The text was updated successfully, but these errors were encountered: