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

Error on mrb_str_cat function (str_buf_cat) #3574

Closed
rmalizia44 opened this Issue Apr 2, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@rmalizia44
Contributor

rmalizia44 commented Apr 2, 2017

Everytime I create a Ruby String and call mrb_str_cat it gives a Segmentation Fault (using Linux Ubuntu).

Example Code:

mrb_value new_obj = mrb_obj_new(mrb, mrb->string_class, 0, NULL);
const char* test_str = "test";
new_obj = mrb_str_cat(mrb, new_obj, test_str, 4);

I reverted str_buf_cat master to 1.2.0 on "string.c" and the Segmentation Fault stopped.

@fundamental

This comment has been minimized.

Show comment
Hide comment
@fundamental

fundamental Apr 2, 2017

Just a guess, but that sounds like new_obj is not fully initialized. Perhaps try using mrb_str_new_lit() to initialize it.

fundamental commented Apr 2, 2017

Just a guess, but that sounds like new_obj is not fully initialized. Perhaps try using mrb_str_new_lit() to initialize it.

@matz

This comment has been minimized.

Show comment
Hide comment
@matz

matz Apr 3, 2017

Member

Yes, use mrb_str_new* to create string objects.

Member

matz commented Apr 3, 2017

Yes, use mrb_str_new* to create string objects.

@matz matz closed this Apr 3, 2017

matz added a commit that referenced this issue Apr 3, 2017

@rmalizia44

This comment has been minimized.

Show comment
Hide comment
@rmalizia44

rmalizia44 Apr 3, 2017

Contributor

mrb_str_new worked! Thanks very much!

Contributor

rmalizia44 commented Apr 3, 2017

mrb_str_new worked! Thanks very much!

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