This is an archive of the discontinued LLVM Phabricator instance.

[sanitizers] Fixes strndup API behaviour when intercepted by sanitizers
ClosedPublic

Authored by kmnls on May 26 2022, 1:45 AM.

Details

Summary

Sanitizers ignore flag allocator_may_return_null=1 in strndup() calls.
When OOM is emulated, this causes to the unexpected crash.

Diff Detail

Event Timeline

kmnls created this revision.May 26 2022, 1:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2022, 1:45 AM
kmnls requested review of this revision.May 26 2022, 1:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2022, 1:45 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
kmnls added a reviewer: kcc.May 26 2022, 1:49 AM
kmnls planned changes to this revision.May 26 2022, 2:24 AM
kmnls updated this revision to Diff 432334.May 26 2022, 11:10 AM

[sanitizer] Update test, check error, return proper value, print error.

kmnls removed a reviewer: kcc.May 26 2022, 11:09 PM
kmnls updated this revision to Diff 432544.May 27 2022, 6:46 AM

[sanitizers] Revert testcase code as not related

kmnls added a reviewer: kcc.May 27 2022, 7:23 AM
kmnls added a comment.May 30 2022, 5:11 AM

@kcc @morehouse @ccross @pgousseau Could you please review this fix.

This revision is now accepted and ready to land.May 30 2022, 5:38 AM
kmnls added a comment.EditedMay 30 2022, 8:47 AM

@pgousseau Would you take some of your valuable time to commit this patch for my behalf, please?

If you make your first contributions to the LLVM infrastructure, you are unlikely to have commit access. In this case, ask the reviewers to commit the change for you after it has been accepted. [DevPolicy]
Prior to obtaining commit access, it is common practice to request that someone with commit access commits on your behalf. When doing so, please provide the name and email address you would like to use in the Author property of the commit. [DevPolicy]

Author property: Kostyantyn Melnik, kmnls.kmnls@gmail.com

@pgousseau Would you take some of your valuable time to commit this patch for my behalf, please?

If you make your first contributions to the LLVM infrastructure, you are unlikely to have commit access. In this case, ask the reviewers to commit the change for you after it has been accepted. [DevPolicy]
Prior to obtaining commit access, it is common practice to request that someone with commit access commits on your behalf. When doing so, please provide the name and email address you would like to use in the Author property of the commit. [DevPolicy]

Author property: Kostyantyn Melnik, kmnls.kmnls@gmail.com

With pleasure, done now!