This is an archive of the discontinued LLVM Phabricator instance.

[libc++abi] Add a rate limiter when logging dynamic_cast errors
ClosedPublic

Authored by ldionne on Apr 16 2020, 2:09 PM.

Details

Summary

This upstreams a fix that Howard made a long time ago, where so many
errors would be logged that applications were becoming sluggish. With
this patch, the first three errors will be printed, and after that the
printing frequency decreases exponentially.

_LIBCXX_DYNAMIC_FALLBACK is only enabled on Apple platforms, so this
should be NFC for other platforms.

rdar://14996273

Diff Detail

Event Timeline

ldionne created this revision.Apr 16 2020, 2:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 16 2020, 2:09 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne updated this revision to Diff 259070.Apr 21 2020, 12:12 PM

Make the counter thread-safe per offline discussion with Michael

This revision was not accepted when it landed; it landed in state Needs Review.Apr 21 2020, 12:28 PM
This revision was automatically updated to reflect the committed changes.
jfb added a comment.Apr 21 2020, 3:20 PM

You probably want to assert that std::atomic<size_t>::is_always_lock_free so weird platforms don't suddenly require a lock, or the lock shard.

In D78330#1995574, @jfb wrote:

You probably want to assert that std::atomic<size_t>::is_always_lock_free so weird platforms don't suddenly require a lock, or the lock shard.

I agree, but we build libcxxabi as C++11, not C++17 :-(. As soon as we upgrade our CMake, I'll change libcxx and libcxxabi to build as C++17 and I'll fix that.

jfb added a comment.Apr 22 2020, 8:45 AM
In D78330#1995574, @jfb wrote:

You probably want to assert that std::atomic<size_t>::is_always_lock_free so weird platforms don't suddenly require a lock, or the lock shard.

I agree, but we build libcxxabi as C++11, not C++17 :-(. As soon as we upgrade our CMake, I'll change libcxx and libcxxabi to build as C++17 and I'll fix that.

☹️

_Static_assert(__atomic_always_lock_free(sizeof(size_t), 0), "");

🤫