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

Crash when insert an invalid char in array, and object #68

Closed
stokhos opened this issue Jan 4, 2021 · 4 comments · Fixed by #71
Closed

Crash when insert an invalid char in array, and object #68

stokhos opened this issue Jan 4, 2021 · 4 comments · Fixed by #71
Labels
bug Something isn't working crash

Comments

@stokhos
Copy link
Contributor

stokhos commented Jan 4, 2021

Insert invalid cha c in array and object will cause the problem.

This problem is related to cursor location.

sapling/src/editor/dag.rs

Lines 410 to 415 in 9fed519

if !parent.is_valid_child(cursor_index, c) {
// Short circuit if `c` couldn't be a valid child of the cursor
return Err(EditErr::CannotBeChild {
c,
parent_name: cursor.display_name(),
});

``

@stokhos stokhos changed the title crash when insert an invalid char in array, and object Crash when insert an invalid char in array, and object Jan 4, 2021
@kneasle
Copy link
Owner

kneasle commented Jan 4, 2021

This crashes regardless of which node is under the cursor dw about this - I was getting confused with a different crash bug. I've found a fix, and I'm making regression tests for this.

@kneasle
Copy link
Owner

kneasle commented Jan 4, 2021

Actually, if #63 is fixed then this bug will not be possible.

@kneasle kneasle added bug Something isn't working crash labels Jan 4, 2021
kneasle added a commit that referenced this issue Jan 4, 2021
This fixes #68 when inserting into nodes that can't have children.
kneasle added a commit that referenced this issue Jan 4, 2021
@kneasle kneasle mentioned this issue Jan 4, 2021
kneasle added a commit that referenced this issue Jan 4, 2021
@kneasle kneasle closed this as completed in 9ff7031 Jan 4, 2021
@kneasle
Copy link
Owner

kneasle commented Jan 4, 2021

Oh whoops, this was accidentally closed because of some silly commit wording 😆 who knew.

@kneasle kneasle reopened this Jan 4, 2021
@kneasle
Copy link
Owner

kneasle commented Jan 5, 2021

I've been doing some digging, and the cause of the problem is that Json::is_valid_child returns a blanket true if the node being inserted into is Json::Object or Json::Array. By extension, this also returns true for invalid characters, and so an error is not returned, and so Json::from_char is called and then unwrapped, causing the crash.

This will be fixed along with #63, because Json::is_valid_child will take a type-safe intermediate type and so it isn't possible to insert an invalid node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants