Closed dpritchLibre closed 6 years ago
I also see this locally
Minimal reprex is obj_size(mean)
But doesn't crash for any of these:
obj_size(sum)
obj_size(function(x, ...) UseMethod("mean"))
Also crashes on obj_size(sd)
(so not related to S3-ness)
Crashes when iterating through BODY(x)
:
case DOTSXP:
case LISTSXP:
case LANGSXP:
case BCODESXP:
if (x == R_MissingArg) // Needed for DOTSXP
break;
for(SEXP cons = x; cons != R_NilValue; cons = CDR(cons)) {
if (cons != x)
size += sizeof_node;
size += obj_size_tree(TAG(cons), base_env, sizeof_node, sizeof_vector, seen);
size += obj_size_tree(CAR(cons), base_env, sizeof_node, sizeof_vector, seen);
}
But obj_size(body(sd))
works
Ah body()
uses BODY_EXPR()
while obj_size()
uses BODY()
.
Because the code for iterating over the bytecode (which BODY()
returns but BODY_EXPR()
does not) was broken.
When I try to run the example in Exercise 2 of Section 2.4.1 in the second edition of Advanced R, I am getting a segfault on a call to
lobstr::obj_size
. The example code is shown below. I would be happy to work on a fix if it turns out to not be just a dependency issue or something similar, and given some direction.