This is an archive of the discontinued LLVM Phabricator instance.

Add invariant on <long string cap> >= __min_cap and change brittle __was_long cases
AbandonedPublic

Authored by mvels on Jan 21 2020, 12:57 PM.

Details

Reviewers
EricWF
mclow.lists
Group Reviewers
Restricted Project
Summary

The partial inlining optimization for short strings could allocate strings at min_cap size. Code in grow_by assumed cap != __min_cap - 1 as proof that the input is an allocated long string leading to bad deallocation.

  • add the invariant that no long string should have <= min_cap capacity
  • use actual is_long() for 'was_long' observation in __grow_by logic for robustness / readability

Combined these defend against both the (previously not expressed) invariant and its consequences.

Diff Detail

Event Timeline

mvels created this revision.Jan 21 2020, 12:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2020, 12:57 PM
mvels edited the summary of this revision. (Show Details)Jan 22 2020, 10:43 AM
mvels edited the summary of this revision. (Show Details)
mvels updated this revision to Diff 271827.Jun 18 2020, 1:23 PM

Cleaned up const char* ternary, evaluating traits_type::length for all constant strings

Herald added a reviewer: Restricted Project. · View Herald TranscriptJun 18 2020, 1:23 PM
Herald added a subscriber: jfb. · View Herald Transcript
mvels abandoned this revision.Jun 18 2020, 1:24 PM
libcxx/include/string