In Annotation::SetSize, use AnnotationList::Register rather than Get.

In Chromium, the AnnotationList is registered in the main executable
module. However, when using the component build, the individual shared
libraries do not explicitly initialize the CrashpadInfo nor
AnnotationList. This causes annotations to NULL-dereference the
uninitialized AnnotationList when using the component build.

By using the Register method instead, the AnnotationList will be lazily
created. In Chromium's static/release build, the AnnotationList will
still be initialized deterministically during startup.

Bug: crashpad:192
Change-Id: I8599b52630f4d7608e5028b14264a8eed49a9176
Reviewed-on: https://chromium-review.googlesource.com/793981
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Robert Sesek 2017-11-28 13:28:41 -05:00 committed by Commit Bot
parent 0d05b0d59e
commit af28b83eb7

View File

@ -30,7 +30,9 @@ constexpr size_t Annotation::kValueMaxSize;
void Annotation::SetSize(ValueSizeType size) {
DCHECK_LT(size, kValueMaxSize);
size_ = size;
AnnotationList::Get()->Add(this);
// Use Register() instead of Get() in case the calling module has not
// explicitly initialized the annotation list, to avoid crashing.
AnnotationList::Register()->Add(this);
}
void Annotation::Clear() {