lobstr icon indicating copy to clipboard operation
lobstr copied to clipboard

Bad binding access

Open mjsteinbaugh opened this issue 3 years ago • 20 comments

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 avatar Sep 23 '20 13:09 mjsteinbaugh

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

mjsteinbaugh avatar Sep 23 '20 13:09 mjsteinbaugh

Can you provide a reprex?

hadley avatar Dec 04 '20 18:12 hadley

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.

PinkAppleFlower avatar Dec 11 '20 15:12 PinkAppleFlower

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

hadley avatar Dec 11 '20 17:12 hadley

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.

PinkAppleFlower avatar Dec 11 '20 18:12 PinkAppleFlower

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

hadley avatar Dec 11 '20 19:12 hadley

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 avatar Dec 11 '20 20:12 PinkAppleFlower

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.

PinkAppleFlower avatar Jan 07 '21 11:01 PinkAppleFlower

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.

hadley avatar Jan 07 '21 13:01 hadley

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)

PinkAppleFlower avatar Jan 07 '21 19:01 PinkAppleFlower

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).

hadley avatar Jan 07 '21 19:01 hadley

No problem. I will do it shortly.

Sent from my iPhone

On Jan 7, 2021, at 12:28 PM, Hadley Wickham [email protected] wrote:

 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).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

PinkAppleFlower avatar Jan 07 '21 21:01 PinkAppleFlower

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)

PinkAppleFlower avatar Jan 07 '21 22:01 PinkAppleFlower

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 avatar Jun 21 '22 21:06 hadley

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 avatar Jun 21 '22 21:06 hadley

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

hadley avatar Jun 21 '22 21:06 hadley

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.

hadley avatar Jun 22 '22 14:06 hadley

Cool thanks @hadley !

mjsteinbaugh avatar Jun 22 '22 17:06 mjsteinbaugh