tidyverse / dplyr

dplyr: A grammar of data manipulation
https://dplyr.tidyverse.org/
Other
4.78k stars 2.12k forks source link

Compound filter hangs #4055

Closed hadley closed 5 years ago

hadley commented 5 years ago
library(dplyr)

df <- structure(list(date = structure(c(17244, 17092, 17179, 17182, 
17213, 17216), class = "Date"), is_package = c(FALSE, FALSE, 
FALSE, FALSE, FALSE, FALSE)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -6L))

# OK
df %>% filter(is_package)
# OK
df %>% filter(date > as.Date("2016-01-01"))
# hangs
df %>% filter(is_package, date > as.Date("2016-01-01"))

If I break execution in a debugger, I see:

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x0000000100185b1d libR.dylib`Rf_findVarInFrame3(rho=0x0000000108fb3e80, symbol=0x0000000109f20d20, doGet=TRUE) at envir.c:1043 [opt]
    frame #1: 0x00000001001eb8e3 libR.dylib`findFunInEnvRange(symbol=0x0000000109f20d20, rho=0x0000000108fb3e80, target=0x00000001018034a8) at objects.c:172 [opt]
    frame #2: 0x00000001001eb794 libR.dylib`R_LookupMethod(method=0x0000000109f20d20, rho=0x000000010d5c0350, callrho=<unavailable>, defrho=0x00000001018538f0) at objects.c:300 [opt]
    frame #3: 0x00000001001ebcde libR.dylib`Rf_usemethod(generic="$", obj=<unavailable>, call=<unavailable>, args=<unavailable>, rho=0x000000010d5c0350, callrho=0x000000010d5c0740, defrho=0x0000000101803470, ans=0x00007ffeefbf20d8) at objects.c:436 [opt]
    frame #4: 0x00000001001b3722 libR.dylib`tryDispatch(generic="$", call=<unavailable>, x=<unavailable>, rho=0x000000010d5c0740, pv=0x00007ffeefbf20d8) at eval.c:5197 [opt]
    frame #5: 0x00000001001a2f75 libR.dylib`bcEval(body=<unavailable>, rho=0x000000010d5c0740, useCache=<unavailable>) at eval.c:6920 [opt]
    frame #6: 0x00000001001977db libR.dylib`Rf_eval(e=<unavailable>, rho=<unavailable>) at eval.c:624[opt]
    frame #7: 0x00000001001aa14c libR.dylib`R_execClosure(call=0x0000000109f13308, newrho=0x000000010d5c0740, sysparent=<unavailable>, rho=<unavailable>, arglist=<unavailable>, op=<unavailable>) at eval.c:0 [opt]
    frame #8: 0x000000010019c7f3 libR.dylib`bcEval(body=<unavailable>, rho=0x000000010d5c0af8, useCache=<unavailable>) at eval.c:6749 [opt]
    frame #9: 0x00000001001977db libR.dylib`Rf_eval(e=<unavailable>, rho=<unavailable>) at eval.c:624[opt]
    frame #10: 0x00000001001aa14c libR.dylib`R_execClosure(call=0x000000010d5c0c10, newrho=0x000000010d5c0af8, sysparent=<unavailable>, rho=<unavailable>, arglist=<unavailable>, op=<unavailable>) at eval.c:0 [opt]
    frame #11: 0x000000010019c7f3 libR.dylib`bcEval(body=<unavailable>, rho=0x000000010d5c0cb8, useCache=<unavailable>) at eval.c:6749 [opt]
    frame #12: 0x00000001001977db libR.dylib`Rf_eval(e=<unavailable>, rho=<unavailable>) at eval.c:624 [opt]
    frame #13: 0x00000001001aa14c libR.dylib`R_execClosure(call=0x0000000109f0f928, newrho=0x000000010d5c0cb8, sysparent=<unavailable>, rho=<unavailable>, arglist=<unavailable>, op=<unavailable>) at eval.c:0 [opt]
    frame #14: 0x00000001001ec21f libR.dylib`dispatchMethod(op=0x0000000109f0c268, sxp=0x0000000109f0f928, dotClass=0x0000000101850fc0, cptr=0x00007ffeefbf4840, method=0x00000001018d8a88, generic=<unavailable>, rho=0x000000010d5c1038, callrho=0x000000010d5ba008, defrho=0x00000001018538f0) at objects.c:408 [opt]
    frame #15: 0x00000001001ebed2 libR.dylib`Rf_usemethod(generic="as.Date", obj=<unavailable>, call=<unavailable>, args=<unavailable>, rho=0x000000010d5c1038, callrho=0x000000010d5ba008, defrho=0x00000001018538f0, ans=0x00007ffeefbf4060) at objects.c:448 [opt]
    frame #16: 0x00000001001ec488 libR.dylib`do_usemethod(call=0x0000000109f0c188, op=<unavailable>, args=<unavailable>, env=0x000000010d5c1038) at objects.c:524 [opt]
    frame #17: 0x000000010019cda9 libR.dylib`bcEval(body=<unavailable>, rho=0x000000010d5c1038, useCache=<unavailable>) at eval.c:6801 [opt]
    frame #18: 0x00000001001977db libR.dylib`Rf_eval(e=<unavailable>, rho=<unavailable>) at eval.c:624 [opt]
    frame #19: 0x00000001001aa14c libR.dylib`R_execClosure(call=0x0000000109f0c268, newrho=0x000000010d5c1038, sysparent=<unavailable>, rho=<unavailable>, arglist=<unavailable>, op=<unavailable>) at eval.c:0 [opt]
hadley commented 5 years ago

With fresh install from from GitHub

yutannihilation commented 5 years ago

I think this is a duplicate of #4049. The code works on #4054's branch.

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

packageDescription("dplyr")[c("GithubRef", "GithubSHA1")]
#> $GithubRef
#> [1] "fix-tidyeval-infloop"
#> 
#> $GithubSHA1
#> [1] "0599ed464521f930d27ebf654b2bdeb8eaaec673"

df <- structure(list(date = structure(c(17244, 17092, 17179, 17182, 
17213, 17216), class = "Date"), is_package = c(FALSE, FALSE, 
FALSE, FALSE, FALSE, FALSE)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -6L))

df %>% filter(is_package)
#> # A tibble: 0 x 2
#> # … with 2 variables: date <date>, is_package <lgl>
df %>% filter(date > as.Date("2016-01-01"))
#> # A tibble: 6 x 2
#>   date       is_package
#>   <date>     <lgl>     
#> 1 2017-03-19 FALSE     
#> 2 2016-10-18 FALSE     
#> 3 2017-01-13 FALSE     
#> 4 2017-01-16 FALSE     
#> 5 2017-02-16 FALSE     
#> 6 2017-02-19 FALSE
df %>% filter(is_package, date > as.Date("2016-01-01"))
#> # A tibble: 0 x 2
#> # … with 2 variables: date <date>, is_package <lgl>

Created on 2018-12-25 by the reprex package (v0.2.1)

hadley commented 5 years ago

Thanks @yutannihilation!

lock[bot] commented 5 years ago

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/