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

DAOS-6979 csum: Fixes detected by NLT #4915

Merged
merged 1 commit into from
Mar 11, 2021

Conversation

ryon-jensen
Copy link
Contributor

  • Now Using DF_RC where appropriate.
  • Renamed pointer for allocation so NLT can detect
    where the allocation is freed.
  • Added missing check if memory was allocated

Signed-off-by: Ryon Jensen ryon.jensen@intel.com

- Now Using DF_RC where appropriate.
- Renamed pointer for allocation so NLT can detect
  where the allocation is freed.

Signed-off-by: Ryon Jensen <ryon.jensen@intel.com>
Copy link
Collaborator

@daosbuild1 daosbuild1 left a comment

Choose a reason for hiding this comment

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

LGTM. No errors found by checkpatch.

@kprantis
Copy link
Contributor

Is this ready for gatekeeping now?

@ryon-jensen
Copy link
Contributor Author

The failure is also seen on master (DAOS-6997). Di is working a fix, but don't think this patch is blocked by it, so requesting force land.

@ryon-jensen ryon-jensen requested a review from a team March 10, 2021 23:39
D_FREE(iod_csum->ic_data);
}

rc = proc_struct_dcs_csum_info(proc, &iod_csum->ic_akey);
if (unlikely(rc)) {
D_FREE(iod_csum->ic_data);
Copy link
Contributor

Choose a reason for hiding this comment

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

minor, D_FREE(iod_csum->ic_data) possibly call twice in L216 and L221, D_FREE will not check NULL internally, so better to check if it is NULL here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree. Both free() and D_FREE() accept NULL, and in fact we encourage calling D_FREE with null rather than checking to improve readability of both the code and the logs. D_FREE() will set the pointer to NULL so as long as the same variable is called twice it's OK because the first one will have free it but the second one won't.

Copy link
Contributor

@ashleypittman ashleypittman left a comment

Choose a reason for hiding this comment

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

From the commit message:

Renamed pointer for allocation so NLT can detect
where the allocation is freed.

NLT does not take into consideration the name of the pointer, just the value when doing the free check, although it logs the name. I suspect you've renamed something here that you didn't need to.

These changes are good, and in line with how we want errors to be reported, however I also notice that there is no change in NLT results in CI so how did you go about finding them? It may be that you have some additional testing you'd like to add to NLT that managed to expose these error paths?

Comment on lines +195 to +196
if (iod_csum->ic_data == NULL)
return -DER_NOMEM;
Copy link
Contributor

Choose a reason for hiding this comment

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

This would have resulted in a segfault here before presumably?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if memory failed to be allocated then a segfault would have probably occurred when ic_data was attempted to be accessed.

Copy link
Contributor

Choose a reason for hiding this comment

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

This warrants it's own ticket and a 1.2 backport then I assume?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, probably would have, and I debated this with myself, but I ended up lumping all the fixes for the issues reported by NLT into one patch. I will work on the backport.

D_FREE(iod_csum->ic_data);
}

rc = proc_struct_dcs_csum_info(proc, &iod_csum->ic_akey);
if (unlikely(rc)) {
D_FREE(iod_csum->ic_data);
Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree. Both free() and D_FREE() accept NULL, and in fact we encourage calling D_FREE with null rather than checking to improve readability of both the code and the logs. D_FREE() will set the pointer to NULL so as long as the same variable is called twice it's OK because the first one will have free it but the second one won't.

@ryon-jensen ryon-jensen requested a review from a team March 11, 2021 15:28
@ryon-jensen
Copy link
Contributor Author

Got approval on behalf of gatekeeper, but need gatekeeper to land :-) ... Requesting gatekeeper again.

@ryon-jensen
Copy link
Contributor Author

From the commit message:

Renamed pointer for allocation so NLT can detect
where the allocation is freed.

NLT does not take into consideration the name of the pointer, just the value when doing the free check, although it logs the name. I suspect you've renamed something here that you didn't need to.

These changes are good, and in line with how we want errors to be reported, however I also notice that there is no change in NLT results in CI so how did you go about finding them? It may be that you have some additional testing you'd like to add to NLT that managed to expose these error paths?

@ashleypittman - The NLT errors were found on another PR where checksums are enabled by default. The purpose of that PR is to just run CI with checksums, but won't actually be landed (at least for a while), and I wanted to get these fixes in now.

@jolivier23 jolivier23 merged commit 7cb7d97 into master Mar 11, 2021
@jolivier23 jolivier23 deleted the ryon-jensen/NltFixes_DAOS-6979 branch March 11, 2021 17:24
ryon-jensen added a commit that referenced this pull request Mar 16, 2021
- Now Using DF_RC where appropriate.
- Renamed pointer for allocation so NLT can detect
  where the allocation is freed.

Signed-off-by: Ryon Jensen <ryon.jensen@intel.com>
jolivier23 pushed a commit that referenced this pull request Mar 18, 2021
- Now Using DF_RC where appropriate.
- Renamed pointer for allocation so NLT can detect
  where the allocation is freed.

Signed-off-by: Ryon Jensen <ryon.jensen@intel.com>
@ashleypittman ashleypittman mentioned this pull request Apr 28, 2021
@ashleypittman ashleypittman mentioned this pull request May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants