This is an archive of the discontinued LLVM Phabricator instance.

[libc] Make the bump pointer explicitly return null on buffer oveerrun
ClosedPublic

Authored by jhuber6 on May 14 2023, 10:07 AM.

Details

Summary

We use a simple bump ptr in the libc tests. If we run out of data we
can currently return other static memory and have weird failure cases.
We should fail more explicitly here by returning a null pointer instead.

Diff Detail

Event Timeline

jhuber6 created this revision.May 14 2023, 10:07 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 14 2023, 10:07 AM
jhuber6 requested review of this revision.May 14 2023, 10:07 AM
sivachandra accepted this revision.May 14 2023, 10:12 PM
sivachandra added inline comments.
libc/test/IntegrationTest/test.cpp
60

s/uint64_t/ptrdiff_t ?
s/memory_size/MEMORY_SIZE

60–61

s/16384/MEMORY_SIZE

69

s/uint64_t/ptrdiff_t?

libc/test/UnitTest/HermeticTestUtils.cpp
32–33

Ditto.

This revision is now accepted and ready to land.May 14 2023, 10:12 PM
jhuber6 marked 3 inline comments as done.May 15 2023, 4:15 AM
jhuber6 added inline comments.
libc/test/IntegrationTest/test.cpp
69

The size is unsigned so we'll get warnings about the comparison. Since we know ptr >= memory we know that this will never be negative.