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 error in read_sample()/take_sample() operations with Datasharing [12130] #2070

Merged
merged 7 commits into from
Jul 19, 2021

Conversation

richiware
Copy link
Member

The bug was reproduced when reader's history is 1 depth and while read_sample()/take_sample() operation is deserializing the data, the data is overwritten by the datawriter. The ReadTakeCommand returned OK and the code tries to access a 0 length vector.

Also the code was changed to return NO_DATA if the operation will return no data.

@richiware richiware changed the title Fix error in read_sample()/take_sample() operations with Datasharing Fix error in read_sample()/take_sample() operations with Datasharing [12130] Jul 15, 2021
@MiguelCompany
Copy link
Member

Also the code was changed to return NO_DATA if the operation will return no data.

Instead of doing this, we could add the following lines on DataReaderImpl::read_or_take_next_sample, right after ReturnCode_t code = cmd.return_value();

    if ((ReturnCode_t::RETCODE_OK == code) && (0 == sample_infos.length()))
    {
        code = ReturnCode_t::RETCODE_NO_DATA;
    }

@MiguelCompany
Copy link
Member

@richiware I would also add a regression test for read_next_sample

@MiguelCompany MiguelCompany added this to the v2.3.4 milestone Jul 16, 2021
@richiware richiware force-pushed the bugfix/read_take_error branch from df00e6d to 985d320 Compare July 16, 2021 06:11
@richiware
Copy link
Member Author

@MiguelCompany Regression test was implemented.

About your conditional statement suggestion in the read_or_take_next_sample(), I'm not sure. It will only fix the error in the read_next_sample/take_next_samplefunctions.
In case of calling read/take function with one sample in the history and the deserialization of that change fails, the function will return OK.

MiguelCompany
MiguelCompany previously approved these changes Jul 16, 2021
Copy link
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

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

LGTM with green CI

MiguelCompany
MiguelCompany previously approved these changes Jul 16, 2021
@MiguelCompany
Copy link
Member

@richiware This needs a rebase

richiware and others added 7 commits July 19, 2021 08:19
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
@richiware
Copy link
Member Author

Rebase was done.

Copy link
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

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

LGTM with green CI

@MiguelCompany MiguelCompany merged commit 22aeba4 into master Jul 19, 2021
@MiguelCompany MiguelCompany deleted the bugfix/read_take_error branch July 19, 2021 07:47
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