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

fix #34159, crash in deserialize caused by recent layout changes #34163

Merged
merged 1 commit into from
Dec 23, 2019

Conversation

JeffBezanson
Copy link
Member

The field types are not necessarily available at this point in deserialization. I also like this implementation a bit better since it always handles null-ing C pointers on the serialize side.

@JeffBezanson JeffBezanson added the bugfix This change fixes an existing bug label Dec 20, 2019
src/dump.c Outdated
ios_write(s->s, (char*)&n, sizeof(n));
last = ptr + sizeof(n);
}
else if (j < np && ptr == (char*)&((jl_value_t**)data)[jl_ptr_offset(t, j)]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs while ptr > jl_ptr_offset(t, j) { /* write out previous field */ }

@vtjnash
Copy link
Member

vtjnash commented Dec 20, 2019

Agreed. This is a better approach. I was alternatively also thinking about copying the value into temporary space (copy = memcpy(malloc(sz), src, sz)), then iterating fields to clear the pointers inside that copy, then serializing out the copied memory.

src/dump.c Outdated
ios_write(s->s, last, prevptr - last);
jl_value_t *e = *(jl_value_t**)prevptr;
JL_GC_PROMISE_ROOTED(e);
if (t->mutabl && e && jl_is_cpointer(e) && jl_unbox_voidpointer(e) != (void*)-1 && jl_unbox_voidpointer(e) != NULL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want jl_field_type(t, i)->mutabl here (but that's always false)

Suggested change
if (t->mutabl && e && jl_is_cpointer(e) && jl_unbox_voidpointer(e) != (void*)-1 && jl_unbox_voidpointer(e) != NULL)
if (0)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, we need some kind of check for whether this is a direct field of the object. Maybe checking that jl_field_type(t, i-1) is concrete and inlinealloc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. We probably want t->mutable && jl_field_isptr(t, i - 1) && jl_is_cpointer(e) && then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants