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

mrb_str_modify tries to write to static string #3373

clayton-shopify opened this Issue Jan 5, 2017 · 0 comments


None yet
1 participant

clayton-shopify commented Jan 5, 2017

The following code demonstrates a crash:

a = # allocates static string
a[0] # converts to shared string
GC.start # reduces refcnt to 1?! #crash

The crash occurs here, where an attempt is made to write to a static string's buffer (which is not writeable):

RSTR_PTR(s)[s->as.heap.len] = '\0';

The crash is not particular to Time#zone; the first line can be changed to anything that allocates a static string, e.g. a = :a.to_s.

I haven't investigated further, so I'm not sure what the right fix is.

This issue was reported by

@matz matz closed this in f53f73f Jan 6, 2017

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