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

[BUGZILLA #16441] Segfault when an environment has an attribute that refers to itself #5837

Open
MichaelChirico opened this issue May 18, 2020 · 1 comment

Comments

@MichaelChirico
Copy link
Owner

When an environment has a reference to itself in an attribute, it can result in a segfault when trying to inspect the environment.

# This is OK
e <- new.env()
e$e <- e
object.size(e)
# 56 bytes

# Using attributes causes segfault with object.size
e <- new.env()
attr(e, "e") <- e
object.size(e)
# Segmentation fault

# Similarly with str
e <- new.env()
attr(e, "e") <- e
str(e)
# Segmentation fault


METADATA

  • Bug author - Winston Chang
  • Creation time - 2015-06-22 20:38:58 UTC
  • Bugzilla link
  • Status - ASSIGNED
  • Alias - None
  • Component - Low-level
  • Version - R 3.2.1
  • Hardware - Other Linux
  • Importance - P5 minor
  • Assignee - R-core
  • URL -
  • Modification time - 2015-06-23 16:56 UTC
@MichaelChirico
Copy link
Owner Author

Attributes on environments are always a bad idea. No matter how convenient they may seem, the implementation doesn't support them in a reasonable way.

That said it would be nice not to segfault, which print(e) also does.

I've added some calls to R_Checkstack, which handle the object.size case.
print(e) triggers a buffer overflow in printAttributes; I've added a hack to trap that, but a cleaner rewrite with size checks would be better.
These changes are in r68574 in the trunk and r68575 in R-3-2-branch.

str(e) hilts a problem of cascading error calls when clean-up code is called after signalling an error because a resource is depleted. This is a long-standing issue with the way R calls clean-up code (before the jump instead of doing a series of jumps that release resources). It needs to be fixed eventually but probably won't be soon. I'm leaving the bug open as a reminder.


METADATA

  • Comment author - Luke Tierney
  • Timestamp - 2015-06-23 16:56:23 UTC

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

No branches or pull requests

1 participant