[client] New class LengthDelimitedRingBuffer [crashpad/crashpad : main]

4 views
Skip to first unread message

Ben Hamilton (Gerrit)

unread,
Nov 16, 2022, 7:12:56 PM11/16/22
to Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

Attention is currently required from: Justin Cohen, Mark Mentovai, Robert Sesek.

View Change

    To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: crashpad/crashpad
    Gerrit-Branch: main
    Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
    Gerrit-Change-Number: 4023618
    Gerrit-PatchSet: 18
    Gerrit-Owner: Ben Hamilton <benha...@google.com>
    Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
    Gerrit-CC: Justin Cohen <justi...@chromium.org>
    Gerrit-Attention: Justin Cohen <justi...@chromium.org>
    Gerrit-Attention: Robert Sesek <rse...@chromium.org>
    Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
    Gerrit-Comment-Date: Thu, 17 Nov 2022 00:12:20 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Matthew Fowles Kulukundis (Gerrit)

    unread,
    Nov 22, 2022, 3:54:10 PM11/22/22
    to Ben Hamilton, Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

    Attention is currently required from: Ben Hamilton, Justin Cohen, Mark Mentovai, Robert Sesek.

    View Change

    4 comments:

    • File client/length_delimited_ring_buffer.h:

      • Patch Set #25, Line 17: constexpr uint32_t kDefaultRingBufferCapacity = 8192;

        you need to use `inline constexpr` in headers to avoid ODR violations

      • Patch Set #25, Line 83: copy

        generally memcpy is more common to see then std::copy for things like this

      • Patch Set #25, Line 368: ReadBase128VarintUint32FromRingBuffer

        instead of encoding the lengths using varint, I would just declare a fixed size of length and use that consistently

      • Patch Set #25, Line 436: buffer_length

        prefer explicit comparison with zero to implicit promotion to bool

    To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: crashpad/crashpad
    Gerrit-Branch: main
    Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
    Gerrit-Change-Number: 4023618
    Gerrit-PatchSet: 25
    Gerrit-Owner: Ben Hamilton <benha...@google.com>
    Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
    Gerrit-CC: Justin Cohen <justi...@chromium.org>
    Gerrit-CC: Matthew Fowles Kulukundis <k...@google.com>
    Gerrit-Attention: Ben Hamilton <benha...@google.com>
    Gerrit-Attention: Justin Cohen <justi...@chromium.org>
    Gerrit-Attention: Robert Sesek <rse...@chromium.org>
    Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
    Gerrit-Comment-Date: Tue, 22 Nov 2022 20:53:42 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Ben Hamilton (Gerrit)

    unread,
    Nov 22, 2022, 6:25:22 PM11/22/22
    to Matthew Fowles Kulukundis, Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

    Attention is currently required from: Justin Cohen, Mark Mentovai, Matthew Fowles Kulukundis, Robert Sesek.

    View Change

    4 comments:

    • File client/length_delimited_ring_buffer.h:

      • Patch Set #25, Line 17: constexpr uint32_t kDefaultRingBufferCapacity = 8192;

        you need to use `inline constexpr` in headers to avoid ODR violations

      • Ah, I always miss that. Thanks, done.

      • OK, done.

      • instead of encoding the lengths using varint, I would just declare a fixed size of length and use th […]

        My idea here was to be compatible with existing protobuf logic which knows how to deserialize a list of varint-delimited fields from an array. That makes things a lot simpler on the iOS side, at least.

        If it's OK, I'd like to keep this as-is. But if you feel strongly, I'm happy to change it.

      • Thanks, done.

    To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: crashpad/crashpad
    Gerrit-Branch: main
    Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
    Gerrit-Change-Number: 4023618
    Gerrit-PatchSet: 28
    Gerrit-Owner: Ben Hamilton <benha...@google.com>
    Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
    Gerrit-CC: Justin Cohen <justi...@chromium.org>
    Gerrit-CC: Matthew Fowles Kulukundis <k...@google.com>
    Gerrit-Attention: Matthew Fowles Kulukundis <k...@google.com>
    Gerrit-Attention: Justin Cohen <justi...@chromium.org>
    Gerrit-Attention: Robert Sesek <rse...@chromium.org>
    Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
    Gerrit-Comment-Date: Tue, 22 Nov 2022 23:24:33 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Matthew Fowles Kulukundis <k...@google.com>
    Gerrit-MessageType: comment

    Ben Hamilton (Gerrit)

    unread,
    Nov 23, 2022, 12:11:51 PM11/23/22
    to Matthew Fowles Kulukundis, Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

    Attention is currently required from: Justin Cohen, Mark Mentovai, Matthew Fowles Kulukundis, Robert Sesek.

    View Change

    1 comment:

    • File client/length_delimited_ring_buffer.h:

      • Patch Set #25, Line 368: ReadBase128VarintUint32FromRingBuffer

        My idea here was to be compatible with existing protobuf logic which knows how to deserialize a list […]

        Discussed offline. I added documentation explaining why this uses Base128 varint-delimited encoding and links to the relevant protobuf APIs as an example.

        Matthew suggested returning an error if the Varint128-encoded length would take up more than 2 bytes (2^14 == 16 KiB), but the logic already returns an error if the client invokes `Push()` with a length larger than the capacity of the ringbuffer, so I left that logic as-is in case clients want to push payloads larger than 16 KiB onto the ringbuffer.

    To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: crashpad/crashpad
    Gerrit-Branch: main
    Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
    Gerrit-Change-Number: 4023618
    Gerrit-PatchSet: 29
    Gerrit-Owner: Ben Hamilton <benha...@google.com>
    Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
    Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
    Gerrit-CC: Justin Cohen <justi...@chromium.org>
    Gerrit-Attention: Matthew Fowles Kulukundis <k...@google.com>
    Gerrit-Attention: Justin Cohen <justi...@chromium.org>
    Gerrit-Attention: Robert Sesek <rse...@chromium.org>
    Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
    Gerrit-Comment-Date: Wed, 23 Nov 2022 17:10:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Matthew Fowles Kulukundis <k...@google.com>
    Comment-In-Reply-To: Ben Hamilton <benha...@google.com>
    Gerrit-MessageType: comment

    Matthew Fowles Kulukundis (Gerrit)

    unread,
    Nov 23, 2022, 1:13:19 PM11/23/22
    to Ben Hamilton, Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

    Attention is currently required from: Ben Hamilton, Justin Cohen, Mark Mentovai, Robert Sesek.

    Patch set 30:Commit-Queue +1

    View Change

      To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
      Gerrit-Change-Number: 4023618
      Gerrit-PatchSet: 30
      Gerrit-Owner: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
      Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
      Gerrit-CC: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Ben Hamilton <benha...@google.com>
      Gerrit-Attention: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Robert Sesek <rse...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Wed, 23 Nov 2022 18:12:45 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      Gerrit-MessageType: comment

      Matthew Fowles Kulukundis (Gerrit)

      unread,
      Nov 23, 2022, 3:48:07 PM11/23/22
      to Ben Hamilton, Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

      Attention is currently required from: Ben Hamilton, Justin Cohen, Mark Mentovai, Robert Sesek.

      View Change

      1 comment:

      To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
      Gerrit-Change-Number: 4023618
      Gerrit-PatchSet: 36
      Gerrit-Owner: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
      Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
      Gerrit-CC: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Ben Hamilton <benha...@google.com>
      Gerrit-Attention: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Robert Sesek <rse...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Wed, 23 Nov 2022 20:47:34 +0000

      Robert Sesek (Gerrit)

      unread,
      Dec 14, 2022, 2:21:30 PM12/14/22
      to Ben Hamilton, Matthew Fowles Kulukundis, Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

      Attention is currently required from: Ben Hamilton, Justin Cohen, Mark Mentovai.

      View Change

      1 comment:

      • File client/length_delimited_ring_buffer.h:

        • Patch Set #36, Line 7: #include <optional>

          Same comment on prior CL re: optional. I do think it could be nice to have optional in Crashpad, so I would maybe go with one of the first two suggestsions.

      To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
      Gerrit-Change-Number: 4023618
      Gerrit-PatchSet: 36
      Gerrit-Owner: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
      Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
      Gerrit-CC: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Ben Hamilton <benha...@google.com>
      Gerrit-Attention: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Wed, 14 Dec 2022 19:20:51 +0000

      Ben Hamilton (Gerrit)

      unread,
      Dec 14, 2022, 3:06:09 PM12/14/22
      to Matthew Fowles Kulukundis, Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

      Attention is currently required from: Justin Cohen, Mark Mentovai, Robert Sesek.

      View Change

      1 comment:

      • File client/length_delimited_ring_buffer.h:

        • Same comment on prior CL re: optional. […]

          Looks like Mark is OK with `std::optional` (as long as we don't trigger UB by using operator*/operator-> on an empty optional).

      To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
      Gerrit-Change-Number: 4023618
      Gerrit-PatchSet: 36
      Gerrit-Owner: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
      Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
      Gerrit-CC: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Robert Sesek <rse...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Wed, 14 Dec 2022 20:05:32 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Robert Sesek <rse...@chromium.org>
      Gerrit-MessageType: comment

      Robert Sesek (Gerrit)

      unread,
      Dec 15, 2022, 11:26:23 AM12/15/22
      to Ben Hamilton, Matthew Fowles Kulukundis, Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

      Attention is currently required from: Ben Hamilton, Justin Cohen, Mark Mentovai.

      View Change

      2 comments:

      • File client/length_delimited_ring_buffer.h:

      • File client/length_delimited_ring_buffer_test.cc:

      To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
      Gerrit-Change-Number: 4023618
      Gerrit-PatchSet: 37
      Gerrit-Owner: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
      Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
      Gerrit-CC: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Ben Hamilton <benha...@google.com>
      Gerrit-Attention: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Thu, 15 Dec 2022 16:25:55 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Gerrit-MessageType: comment

      Ben Hamilton (Gerrit)

      unread,
      Dec 15, 2022, 12:10:33 PM12/15/22
      to Matthew Fowles Kulukundis, Crashpad LUCI CQ, Justin Cohen, Robert Sesek, Mark Mentovai, crashp...@chromium.org

      Attention is currently required from: Justin Cohen, Mark Mentovai, Robert Sesek.

      View Change

      2 comments:

      • File client/length_delimited_ring_buffer.h:

        • Argh, so sorry about that. Thanks, fixed.

      • File client/length_delimited_ring_buffer_test.cc:

      To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
      Gerrit-Change-Number: 4023618
      Gerrit-PatchSet: 38
      Gerrit-Owner: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
      Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
      Gerrit-CC: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Robert Sesek <rse...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Thu, 15 Dec 2022 17:09:59 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No

      Robert Sesek (Gerrit)

      unread,
      Dec 15, 2022, 12:20:19 PM12/15/22
      to Ben Hamilton, Robert Sesek, Matthew Fowles Kulukundis, Crashpad LUCI CQ, Justin Cohen, Mark Mentovai, crashp...@chromium.org

      Attention is currently required from: Ben Hamilton, Justin Cohen, Mark Mentovai.

      Patch set 38:Code-Review +1

      View Change

      1 comment:

      To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
      Gerrit-Change-Number: 4023618
      Gerrit-PatchSet: 38
      Gerrit-Owner: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
      Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
      Gerrit-CC: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Ben Hamilton <benha...@google.com>
      Gerrit-Attention: Justin Cohen <justi...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Thu, 15 Dec 2022 17:19:30 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Gerrit-MessageType: comment

      Ben Hamilton (Gerrit)

      unread,
      Dec 15, 2022, 12:26:20 PM12/15/22
      to Robert Sesek, Matthew Fowles Kulukundis, Crashpad LUCI CQ, Justin Cohen, Mark Mentovai, crashp...@chromium.org

      Attention is currently required from: Ben Hamilton, Justin Cohen, Mark Mentovai.

      Patch set 38:Commit-Queue +2

      View Change

        To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: crashpad/crashpad
        Gerrit-Branch: main
        Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
        Gerrit-Change-Number: 4023618
        Gerrit-PatchSet: 38
        Gerrit-Owner: Ben Hamilton <benha...@google.com>
        Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
        Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
        Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
        Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
        Gerrit-CC: Justin Cohen <justi...@chromium.org>
        Gerrit-Attention: Ben Hamilton <benha...@google.com>
        Gerrit-Attention: Justin Cohen <justi...@chromium.org>
        Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
        Gerrit-Comment-Date: Thu, 15 Dec 2022 17:25:45 +0000

        Crashpad LUCI CQ (Gerrit)

        unread,
        Dec 15, 2022, 12:30:56 PM12/15/22
        to Ben Hamilton, Robert Sesek, Matthew Fowles Kulukundis, Justin Cohen, Mark Mentovai, crashp...@chromium.org

        Crashpad LUCI CQ submitted this change.

        View Change

        Approvals: Robert Sesek: Looks good to me Ben Hamilton: Commit
        [client] New class LengthDelimitedRingBuffer

        This CL implements LengthDelimitedRingBuffer, a general-purpose
        ringbuffer suitable for use as a Crashpad Annotation.

        This ringbuffer supports writing variably-sized data delimited by a Base
        128 varint-encoded length separator.

        LengthDelimitedRingBuffer is backed by a std::array, so it has a fixed
        maximum size. It supports reading via RingBufferReader as well as
        writing via RingBufferWriter.

        Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
        Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4023618
        Reviewed-by: Robert Sesek <rse...@chromium.org>
        Commit-Queue: Ben Hamilton <benha...@google.com>
        ---
        M client/BUILD.gn
        A client/length_delimited_ring_buffer.h
        A client/length_delimited_ring_buffer_test.cc
        3 files changed, 853 insertions(+), 0 deletions(-)


        To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: crashpad/crashpad
        Gerrit-Branch: main
        Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
        Gerrit-Change-Number: 4023618
        Gerrit-PatchSet: 39
        Gerrit-Owner: Ben Hamilton <benha...@google.com>
        Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
        Gerrit-Reviewer: Crashpad LUCI CQ <crashpa...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
        Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
        Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
        Gerrit-CC: Justin Cohen <justi...@chromium.org>
        Gerrit-MessageType: merged

        Mark Mentovai (Gerrit)

        unread,
        Jan 27, 2023, 11:01:44 AM1/27/23
        to Crashpad LUCI CQ, Ben Hamilton, Robert Sesek, Matthew Fowles Kulukundis, Justin Cohen, crashp...@chromium.org

        Attention is currently required from: Ben Hamilton.

        View Change

        14 comments:

        • File client/length_delimited_ring_buffer.h:

          • Patch Set #39, Line 18:

            #include <algorithm>
            #include <array>
            #include <limits>
            #include <optional>
            #include <vector>

            #include <stdint.h>
            #include <string.h>

            C system headers come before C++ system headers.

          • Patch Set #39, Line 32: inline constexpr uint32_t kDefaultRingBufferCapacity = 8192;

            Want a type alias for this?

          • Patch Set #39, Line 40:


            static_assert(sizeof(Range) == 8,
            "struct Range is not packed on this platform");

            Why is this important?

          • Patch Set #39, Line 160: << (length * 7);

            Handle overflow? You’re limited to a `uint32_t` result by your own design, but if the buffer’s been trashed, this will keep reading corrupted garbage and subjecting them to comically enormous shifts.

          • Patch Set #39, Line 234: // Every varint encodes to at least 1 byte of data.

            Refer to the discussion on vertical whitespace in later patches in this series. If it’s hard to know when it’s good to stop and take a breath with a blank line, you can use comments as a good hint that “before” and “after” are sufficiently different.

          • Patch Set #39, Line 235: int length = 1;

            This example carries additional value: you’d want a blank line after this, too, because the comment above only applies to this line, not really to anything that follows.

          • Patch Set #39, Line 293: const uint8_t* other_ring_buffer_bytes = reinterpret_cast<const uint8_t*>(buffer) + sizeof(*other_header);

            This went beyond 80 columns. Didn’t run `git cl format`? Now you’ll want to `clang-format` the whole file.

          • Patch Set #39, Line 311: static constexpr uint32_t kMagic = 0xcab00d1e;

            cute ;)

          • Patch Set #39, Line 344: // using CTAD.

            Consider your audience (or audiences!) If your readers know what CTAD is, this comment isn’t necessary. If they don’t know what CTAD is, the comment is helpful, but you just threw a bunch of unpronounceable capital letters in their faces. So as written, this comment doesn’t really address any audience well.

            Don’t send your readers to the dictionary. Spell it out or leave it out.

            Lines 423 and 538 too.

        • File client/length_delimited_ring_buffer_test.cc:

          • Patch Set #39, Line 17:

            #include <array>
            #include <string>
            #include <vector>

            #include <stdint.h>

            C system headers before C++ system headers.

          • Patch Set #39, Line 26: namespace {

            Tests go in `crashpad::test::(unnamed)`.

          • Patch Set #39, Line 27:


            using ::crashpad::LengthDelimitedRingBufferReader;
            using ::crashpad::LengthDelimitedRingBufferWriter;
            using ::crashpad::RingBufferData;

            You won’t need these if you’re properly within `namespace crashpad` or a child thereof.

          • Patch Set #39, Line 28:

            using ::crashpad::LengthDelimitedRingBufferReader;
            using ::crashpad::LengthDelimitedRingBufferWriter;
            using ::crashpad::RingBufferData;

            using ::testing::Eq;
            using ::testing::IsFalse;
            using ::testing::IsTrue;

            The full-qualification leading `::` is almost never done in Crashpad. I guess a couple others have slipped through the cracks, but you’ve added more in this one file than we had to begin with.

          • Patch Set #39, Line 47:

            \xAB"
            "\xCD";

            Not a big deal, but you wrote a bunch of pretty hex digits with lowercase letters, and then suddenly STARTED SHOUTING.

        To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: crashpad/crashpad
        Gerrit-Branch: main
        Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
        Gerrit-Change-Number: 4023618
        Gerrit-PatchSet: 39
        Gerrit-Owner: Ben Hamilton <benha...@google.com>
        Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
        Gerrit-Reviewer: Crashpad LUCI CQ <crashpa...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
        Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
        Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
        Gerrit-CC: Justin Cohen <justi...@chromium.org>
        Gerrit-Attention: Ben Hamilton <benha...@google.com>
        Gerrit-Comment-Date: Fri, 27 Jan 2023 16:01:39 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Gerrit-MessageType: comment

        Ben Hamilton (Gerrit)

        unread,
        Jan 27, 2023, 1:44:00 PM1/27/23
        to Crashpad LUCI CQ, Robert Sesek, Matthew Fowles Kulukundis, Justin Cohen, Mark Mentovai, crashp...@chromium.org

        View Change

        14 comments:

          • Patch Set #39, Line 18:

            #include <algorithm>
            #include <array>
            #include <limits>
            #include <optional>
            #include <vector>

            #include <stdint.h>
            #include <string.h>

            C system headers come before C++ system headers.

          • Done

          • Done

          • Patch Set #39, Line 40:


            static_assert(sizeof(Range) == 8,
            "struct Range is not packed on this platform");

            Why is this important?

          • Since this struct is directly persisted to disk via Annotation, I wanted to make sure its alignment and size doesn't change for any reason (compiler changes, etc.).

            Is there a better way to ensure this? I can take out the static_asserts here and leave them to the RingBufferAnnotation itself, but I figured the error messages would be easier to understand with a few smaller static_asserts.

          • Handle overflow? You’re limited to a `uint32_t` result by your own design, but if the buffer’s been […]

            Done

          • Refer to the discussion on vertical whitespace in later patches in this series. […]

            Done

          • This example carries additional value: you’d want a blank line after this, too, because the comment […]

            Done

          • Patch Set #39, Line 293: const uint8_t* other_ring_buffer_bytes = reinterpret_cast<const uint8_t*>(buffer) + sizeof(*other_header);

          • This went beyond 80 columns. […]

            Done

          • Consider your audience (or audiences!) If your readers know what CTAD is, this comment isn’t necessa […]

            Done

        • File client/length_delimited_ring_buffer_test.cc:

          • Patch Set #39, Line 17:

            #include <array>
            #include <string>
            #include <vector>

            #include <stdint.h>

            C system headers before C++ system headers.

          • Done

          • Done

          • Patch Set #39, Line 27:


            using ::crashpad::LengthDelimitedRingBufferReader;
            using ::crashpad::LengthDelimitedRingBufferWriter;
            using ::crashpad::RingBufferData;

            You won’t need these if you’re properly within `namespace crashpad` or a child thereof.

          • Done

          • Patch Set #39, Line 28:

            using ::crashpad::LengthDelimitedRingBufferReader;
            using ::crashpad::LengthDelimitedRingBufferWriter;
            using ::crashpad::RingBufferData;

            using ::testing::Eq;
            using ::testing::IsFalse;
            using ::testing::IsTrue;

          • The full-qualification leading `::` is almost never done in Crashpad. […]

            Done

          • Not a big deal, but you wrote a bunch of pretty hex digits with lowercase letters, and then suddenly […]

            Done

        To view, visit change 4023618. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: crashpad/crashpad
        Gerrit-Branch: main
        Gerrit-Change-Id: I23ecb4a85ee8e846e1efc6937a5cb089a494d50a
        Gerrit-Change-Number: 4023618
        Gerrit-PatchSet: 39
        Gerrit-Owner: Ben Hamilton <benha...@google.com>
        Gerrit-Reviewer: Ben Hamilton <benha...@google.com>
        Gerrit-Reviewer: Crashpad LUCI CQ <crashpa...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
        Gerrit-Reviewer: Matthew Fowles Kulukundis <k...@google.com>
        Gerrit-Reviewer: Robert Sesek <rse...@chromium.org>
        Gerrit-CC: Justin Cohen <justi...@chromium.org>
        Gerrit-Comment-Date: Fri, 27 Jan 2023 18:43:55 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
        Gerrit-MessageType: comment
        Reply all
        Reply to author
        Forward
        0 new messages