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: fix syscall length calculation #82

Merged
merged 1 commit into from
Dec 12, 2018

Conversation

xxuejie
Copy link
Collaborator

@xxuejie xxuejie commented Dec 11, 2018

No description provided.

@xxuejie xxuejie requested a review from a team December 11, 2018 09:53
machine.memory_mut().store64(size_addr, real_size as u64)?;
let full_size = data.len() - offset;
let real_size = cmp::min(size, full_size);
machine.memory_mut().store64(size_addr, full_size as u64)?;
Copy link
Member

Choose a reason for hiding this comment

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

Why we don't need the length prefix before?

Copy link
Collaborator Author

@xxuejie xxuejie Dec 12, 2018

Choose a reason for hiding this comment

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

This bug already exists before the refactor, but it's not used: previously we have 2 modes: ALL mode and PARTIAL mode. In ALL mode, you can either read all the data or none, there's no way to read partial data. In the other PARTIAL mode, you can read partial data, then get how much data is still available for future reading(which is the length returned here via full_size).

Throughout the building of SDK, it comes to my mind that we might not need 2 modes here, we can just stick to PARTIAL mode and keep the code in CKB simple. So in the refactoring work, I removed ALL mode and only keep PARTIAL mode. But that raises another problem: our original PARTIAL mode implementation has this bug that the returned length here is not calculated correctly, but due to our current SDK either 1) read all data using ALL mode; 2) read a given length of data using PARTIAL mode hence ignoring returned length prefix, this bug is not discovered till now.

@doitian doitian merged commit 6d80ea4 into develop Dec 12, 2018
@doitian doitian deleted the xxuejie/fix-syscall-length-calculation branch December 12, 2018 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants