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

serializing "package_version" object causes infinite recursion #37

Closed
jefshe opened this Issue Nov 20, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@jefshe
Copy link
Contributor

jefshe commented Nov 20, 2017

The following R code causes RProtoBuf to infinitely recurse:

x <- package_version("1.2")
RProtoBuf::serialize_pb(x)

I did some digging and it looks like when this is because when sub indexing the list, the list returns itself:

x <- package_version("1.2")
identical(x,x[[1]])
> TRUE

this causes lapply(obj, rexp_obj) to never terminate.

Perhaps in these situations, we should call unlist?

@eddelbuettel

This comment has been minimized.

Copy link
Owner

eddelbuettel commented Nov 20, 2017

The package_version object is a funny one. For kicks, can you check what happens with these two:

x1 <- as.raw(x)
x2 <- format(x)

I presume these travel fine. I am not quite where we'd have to go to stop the recursion. But your suggested check is a good one. If you have time to dig ...

@jefshe

This comment has been minimized.

Copy link
Contributor Author

jefshe commented Nov 20, 2017

Just raised a PR.
The output I get:

> x1 <- as.raw(x)
Error: (list) object cannot be coerced to type 'raw'
> x2 <- format(x)
> x2
[1] "1.2"
@eddelbuettel

This comment has been minimized.

Copy link
Owner

eddelbuettel commented Nov 20, 2017

No, I meant: what happens when you try to protobuf x1 or x2. I guess x1 is out anyway...

@jefshe

This comment has been minimized.

Copy link
Contributor Author

jefshe commented Nov 20, 2017

> serialize_pb(format(x),NULL)
 [1] 08 00 2a 07 0a 03 31 2e 32 10 00
> unserialize_pb(serialize_pb(format(x),NULL))
[1] "1.2"

Ah, yep works as intended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.