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

future_lapply ran into subscript out of bounds error when function have use $<- with magrittr pipe. #718

Open
yhm-amber opened this issue Mar 25, 2024 · 4 comments
Labels

Comments

@yhm-amber
Copy link

yhm-amber commented Mar 25, 2024

Describe the bug

I got a error Error in e[[4]] : subscript out of bounds when I run this:

future.apply::future_lapply (list (a = list ()), \(x) x %>% `$<-` (abc, ""))

and this will not give me that error:

lapply (list (a = list ()), \(x) x %>% `$<-` (abc, ""))

I tested them both in my rstudio and webr repl.

Reproduce example

> future.apply::future_lapply (list (a = list ()), \(x) `$<-` (x, abc, ""))
$a
$a$abc
[1] ""


> future.apply::future_lapply (list (a = list ()), \(x) x %>% `$<-` (abc, ""))
Error in e[[4]] : subscript out of bounds
> lapply (list (a = list ()), \(x) x %>% `$<-` (abc, ""))
$a
$a$abc
[1] ""


> 

S40325-12314156_io github forkmaintainers iceraven

Expected behavior

This error should not happens here.

Session information

> sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: wasm32-unknown-emscripten (32-bit)
Running under: emscripten

Matrix products: default


locale:
[1] en_US.UTF-8 C           en_US.UTF-8 en_US.UTF-8 en_US.UTF-8
[6] C          

time zone: Asia/Shanghai
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] magrittr_2.0.3

loaded via a namespace (and not attached):
 [1] parallelly_1.37.1   parallel_4.3.3      tools_4.3.3        
 [4] webr_0.3.1          listenv_0.9.1       future.apply_1.11.1
 [7] codetools_0.2-19    digest_0.6.35       globals_0.16.3     
[10] future_1.33.1      
> future::futureSessionInfo()
*** Package versions
future 1.33.1, parallelly 1.37.1, parallel 4.3.3, globals 0.16.3, listenv 0.9.1

*** Allocations
availableCores():
system 
     1 
availableWorkers():
$system
[1] "localhost"


*** Settings
- future.plan=<not set>
- future.fork.multithreading.enable=<not set>
- future.globals.maxSize=<not set>
- future.globals.onReference=<not set>
- future.resolve.recursive=<not set>
- future.rng.onMisuse=<not set>
- future.wait.timeout=<not set>
- future.wait.interval=<not set>
- future.wait.alpha=<not set>
- future.startup.script=<not set>

*** Backends
Number of workers: 1
List of future strategies:
1. sequential:
   - args: function (..., envir = parent.frame())
   - tweaked: FALSE
   - call: NULL

*** Basic tests
Main R session details:
  pid     r    sysname release version nodename machine   login
1  42 4.3.3 Emscripten  3.1.47      #1  host001  wasm32 user002
     user effective_user
1 user001        user001
Worker R session details:
  worker pid     r    sysname release version nodename machine
1      1  42 4.3.3 Emscripten  3.1.47      #1  host001  wasm32
    login    user effective_user
1 user002 user001        user001
Number of unique worker PIDs: 1 (as expected)
> 
@yhm-amber yhm-amber added the bug label Mar 25, 2024
@yhm-amber
Copy link
Author

yhm-amber commented Mar 25, 2024

Why ... %>% '$<-' (...) with future will make this error ? ...

@HenrikBengtsson
Copy link
Owner

Thanks for the report. I tracked this down to:

> f <- function(x) { x %>% `$<-`(abc, "") }
> codetools::findGlobals(f)
Error in e[[4]] : subscript out of bounds

which means this is outside of Futureverse. So, I think you've actually found a bug in the codetools package. I report to its maintainer.

@yhm-amber
Copy link
Author

yhm-amber commented Mar 25, 2024

Thanks for the report. I tracked this down to:

> f <- function(x) { x %>% `$<-`(abc, "") }
> codetools::findGlobals(f)
Error in e[[4]] : subscript out of bounds

which means this is outside of Futureverse. So, I think you've actually found a bug in the codetools package. I report to its maintainer.

Okay, thanks. 😄

And I found that just '$<-' will error, but '[[<-' won't.

Or

foo = `$<-`

at first then use foo will not error also.

@HenrikBengtsson
Copy link
Owner

Yes; I've just reported at https://gitlab.com/luke-tierney/codetools/-/issues/16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants