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

Bad binding access #48

Open
mjsteinbaugh opened this issue Sep 23, 2020 · 23 comments · May be fixed by #63
Open

Bad binding access #48

mjsteinbaugh opened this issue Sep 23, 2020 · 23 comments · May be fixed by #63
Labels
bug an unexpected problem or unintended behavior

Comments

@mjsteinbaugh
Copy link

mjsteinbaugh commented Sep 23, 2020

I'm seeing this error pop up inside of RStudio when attempting to call lobstr::obj_size(). I'm working on attempting to make a reprex. Just wanted to see if this is a known issue that anyone else has come across:

Error in obj_size_(dots, env, size_node(), size_vector()) : 
  bad binding access
Calls: obj_size -> obj_size_
Backtrace:
    █
 1. └─lobstr::obj_size(object)
 2.   └─lobstr:::obj_size_(dots, env, size_node(), size_vector())
@mjsteinbaugh
Copy link
Author

mjsteinbaugh commented Sep 23, 2020

I can also reproduce this error with the legacy pryr::object_size(), whereas utils::object.size() works as expected.

@hadley
Copy link
Member

hadley commented Dec 4, 2020

Can you provide a reprex?

@hadley hadley added the reprex needs a minimal reproducible example label Dec 4, 2020
@PinkAppleFlower
Copy link

I receive this error when attempting to calculate the size of tibble that is a link to Spark data table. Error shows up in both pryr and lobstr with slightly different semantics.

pryr: "<simpleError in object_sizes(list(...), env): bad binding access>"

lobstr: "<simpleError in obj_size_(dots, env, size_node(), size_vector()): bad binding access>"

The pryr information is not meant to be distracting/off topic, but rather hopefully add additional information that is helpful.

Also, I used the tidyft package to calculate object size and that worked.

LMK if you need a reprex or more info.

Thanks.

@hadley
Copy link
Member

hadley commented Dec 11, 2020

A reprex would be very useful because I'll need to figure out what's going wrong in the C code.

@PinkAppleFlower
Copy link

object size reprex zipped.zip

Above is the link to the notebook and the RMD file.

👍

Just let me know if you need anything else.

@hadley
Copy link
Member

hadley commented Dec 11, 2020

Could you please made a small reprex and include it inline?

@PinkAppleFlower
Copy link

Sure, here is just the code for the lobstr package. I hope this is minimal enough.

#Convert the time series data to a tibble
EU_stock_tibl <- ts_tbl(EuStockMarkets)

#Spark Connection
spark_connection <- spark_connect(master = "local")

#Copy data to Spark
EU_stock_spark_link <- copy_to(spark_connection, EU_stock_tibl, "EU_stock_spark", overwrite = TRUE)

#Size
tryCatch({
lobstr::obj_size(EU_stock_spark_link)
},
error = print
)

@PinkAppleFlower
Copy link

Just following up on this to see where things are at and if my code sample worked out as needed. I see it still has the reprex label. Datacamp uses the pypr package, but not the lobstr package in their course. I mentioned this issue to them so I am just following up as the ticket is still in my inbox.

@hadley
Copy link
Member

hadley commented Jan 7, 2021

Could you please rework your reproducible example to use the reprex package ? That makes it easier to see both the input and the output, formatted in such a way that I can easily re-run in a local session.

@PinkAppleFlower
Copy link

Yep, below is the example created with the reprex package. Thanks for letting me know this is what you were looking for.

library(pryr)
#> Registered S3 method overwritten by 'pryr':
#>   method      from
#>   print.bytes Rcpp
library(lobstr)
#> 
#> Attaching package: 'lobstr'
#> The following objects are masked from 'package:pryr':
#> 
#>     ast, mem_used
library(tidyft)
#> 
#> Life's short, use R.
#> 
#> Attaching package: 'tidyft'
#> The following object is masked from 'package:pryr':
#> 
#>     object_size
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:tidyft':
#> 
#>     add_count, anti_join, arrange, count, cummean, distinct, filter,
#>     full_join, group_by, groups, inner_join, lag, lead, left_join,
#>     mutate, nth, pull, relocate, rename, right_join, select,
#>     select_vars, semi_join, slice, slice_head, slice_max, slice_min,
#>     slice_sample, slice_tail, summarise, transmute, ungroup
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tsbox)
library(sparklyr)
#> 
#> Attaching package: 'sparklyr'
#> The following objects are masked from 'package:tidyft':
#> 
#>     distinct, fill, full_join, inner_join, left_join, nest, right_join,
#>     separate, unite, unnest
library(datasets)


EU_stock_tibl <- ts_tbl(EuStockMarkets)


spark_connection <- spark_connect(master = "local")

EU_stock_spark_link <- copy_to(spark_connection, EU_stock_tibl, "EU_stock_spark", overwrite = TRUE)


tryCatch({
  tidyft::object_size(EU_stock_spark_link)
  },
  error = print
)
#> 10.1 Kb

tryCatch({
  pryr::object_size(EU_stock_spark_link)
},
error = print
)
#> <simpleError in object_sizes(list(...), env): bad binding access>

tryCatch({
  lobstr::obj_size(EU_stock_spark_link)
},
error = print
)
#> <simpleError in obj_size_(dots, env, size_node(), size_vector()): bad binding access>

Created on 2021-01-07 by the reprex package (v0.3.0)

@hadley
Copy link
Member

hadley commented Jan 7, 2021

Could you please try to make your reprex a little more minimal by only showing the problem with lobstr, and removing anything that isn't directly related? (e.g. the tryCatch() calls).

@PinkAppleFlower
Copy link

PinkAppleFlower commented Jan 7, 2021 via email

@PinkAppleFlower
Copy link

Okay, the new reprex is posted below. Thank you.

library(lobstr)
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
library(tsbox)
library(sparklyr)
library(datasets)


EU_stock_tibl <- ts_tbl(EuStockMarkets)

spark_connection <- spark_connect(master = "local")

EU_stock_spark_link <- copy_to(spark_connection, EU_stock_tibl, "EU_stock_spark", overwrite = TRUE)

lobstr::obj_size(EU_stock_spark_link)
#> Error in obj_size_(dots, env, size_node(), size_vector()): bad binding access

Created on 2021-01-07 by the reprex package (v0.3.0)

@hadley
Copy link
Member

hadley commented Jun 21, 2022

More minimal reprex:

con <- sparklyr::spark_connect(master = "local")
spark_mtcars <- dplyr::copy_to(con, mtcars, "mtcars", overwrite = TRUE)
lobstr::obj_size(spark_mtcars)
#> Error in obj_size_(dots, env, size_node(), size_vector()): bad binding access

Created on 2022-06-21 by the reprex package (v2.0.1)

@hadley hadley added bug an unexpected problem or unintended behavior and removed reprex needs a minimal reproducible example labels Jun 21, 2022
@hadley
Copy link
Member

hadley commented Jun 21, 2022

More minimal:

con <- sparklyr::spark_connect(master = "local")
lobstr::obj_size(con$state)

Error probably comes from https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/include/Rinlinedfuns.h#L89

@hadley
Copy link
Member

hadley commented Jun 21, 2022

Looks like this is an "immediate binding": https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/doc/notes/immbnd.md#L25

hadley added a commit that referenced this issue Jun 21, 2022
@hadley hadley linked a pull request Jun 21, 2022 that will close this issue
@hadley
Copy link
Member

hadley commented Jun 22, 2022

I have a fix that works locally, but making it work properly will be quite a lot of extra effort so unfortunately probably won't make it for this release.

@mjsteinbaugh
Copy link
Author

Cool thanks @hadley !

@hadley hadley reopened this Jun 22, 2022
@eliotmcintire
Copy link

Are there updates on this?

I am seeing the same error (bad binding access) now with my reproducible package on CRAN with devel versions of R.

I can manually reproduce this with R-devel on my local machines.

The minimal reprex using R-devel is:

lobstr::obj_size(as.environment("package:lobstr"))

This worked with all previous versions of R.

@hadley
Copy link
Member

hadley commented Apr 2, 2024

@eliotmcintire can you please file a new issue?

@juliasilge
Copy link
Member

I'm seeing this same problem in butcher on R-devel, because of the use of lobstr here. It's not for all models, just for nnet, FWIW.

@juliasilge
Copy link
Member

I just used rig to install R-devel and I cannot reproduce the problem locally. 😔

@lionel-
Copy link
Member

lionel- commented Sep 16, 2024

This also came up in the context of Positron as Ark now vendors a lobstr size implementation:

library(brms)
m <- brm(bf(mpg ~ hp + (1 | cyl), sigma ~ cyl), data = mtcars, seed = 123)
lobstr::obj_size(m)
#> Error in obj_size_(dots, env, size_node(), size_vector()) :
#>   bad binding access

See posit-dev/positron#4686 (comment).

The tools discussed at useR! with Luke Tierney will be useful for a fix: https://gist.github.com/lionel-/1ebcbd5ec69c0775d514c329522408a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants