This is an archive of the discontinued LLVM Phabricator instance.

Make some libstd++ formatters safer

Authored by wallace on Nov 23 2021, 10:13 AM.



We need to add checks that ensure that some core variables are valid, so
that we avoid printing out garbage data. The worst that could happen is
that an non-initialized variable is being printed as something with
123123432 children instead of 0.

Diff Detail

Event Timeline

wallace requested review of this revision.Nov 23 2021, 10:13 AM
wallace created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2021, 10:13 AM
danilashtefan accepted this revision.Nov 23 2021, 10:17 AM
This revision is now accepted and ready to land.Nov 23 2021, 10:17 AM
labath added a subscriber: labath.Nov 23 2021, 10:41 AM
labath added inline comments.

It'd be better to be more explicit about the contents of this "uninitialized" memory.
For example you could allocate a char array of an appropriate size, memset it to zero (or whatever), and then cast its address to a map pointer.

Otherwise you run the risk of flakyness due to random data showing up in that block of memory.

wallace added inline comments.Nov 23 2021, 10:53 AM

good one

wallace updated this revision to Diff 389267.Nov 23 2021, 11:13 AM

labath's comment