This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] use the right type for sizeof
ClosedPublic

Authored by yingcong-wu on Apr 26 2023, 1:24 AM.

Details

Summary

x_aliases is an array of string, so to calculate its size, it should
be <size-of-array> times <size-of-element>, which should be
sizeof(char*) instead of sizeof(char**).

Diff Detail

Event Timeline

yingcong-wu created this revision.Apr 26 2023, 1:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 1:24 AM
Herald added a subscriber: Enna1. · View Herald Transcript
yingcong-wu requested review of this revision.Apr 26 2023, 1:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 1:24 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript

Would you like to try to update compiler-rt/test/sanitizer_common/TestCases/Linux/netent.cpp ?

I guess check-msan should trigger if you try to print n_aliases

Would you like to try to update compiler-rt/test/sanitizer_common/TestCases/Linux/netent.cpp ?

I guess check-msan should trigger if you try to print n_aliases

Sure, I will look into that.

Hi @vitalybuka, I think compiler-rt/test/sanitizer_common/TestCases/Linux/netent.cpp does not need updates. This patch does not change the functionality since sizeof(char**) == sizeof(char*), it just makes more sence using sizeof(char *) in the calculation of x_aliases's size.

Oh, I get your idea now, will add some access to n_aliases in a later commit.

  • add some testes for x_aliases
vitalybuka accepted this revision.Apr 27 2023, 4:46 PM

Thanks, LGTM
and yes, check-msan should NOT trigger trigger as size was not actually changed

This revision is now accepted and ready to land.Apr 27 2023, 4:46 PM
vitalybuka edited the summary of this revision. (Show Details)Apr 27 2023, 4:47 PM
This revision was landed with ongoing or failed builds.Apr 27 2023, 4:56 PM
This revision was automatically updated to reflect the committed changes.