Get correct version info from registry [crashpad/crashpad : main]

61 views
Skip to first unread message

Bruce Dawson (Gerrit)

unread,
Feb 8, 2022, 3:14:41 PM2/8/22
to Joshua Peraza, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Joshua Peraza.

Patch set 2:-Commit-Queue

View Change

1 comment:

  • Patchset:

    • Patch Set #2:

      kernel32.dll is no longer a good way to get Windows version information - the registry is the recommended alternative. Any thoughts on this?

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 2
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Attention: Joshua Peraza <jpe...@chromium.org>
Gerrit-Comment-Date: Tue, 08 Feb 2022 20:14:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Joshua Peraza (Gerrit)

unread,
Feb 8, 2022, 3:47:47 PM2/8/22
to Bruce Dawson, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Bruce Dawson.

View Change

4 comments:

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 2
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Attention: Bruce Dawson <bruce...@chromium.org>
Gerrit-Comment-Date: Tue, 08 Feb 2022 20:47:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Mark Mentovai (Gerrit)

unread,
Feb 8, 2022, 3:54:15 PM2/8/22
to Bruce Dawson, Joshua Peraza, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Bruce Dawson.

View Change

10 comments:

  • File snapshot/win/system_snapshot_win.cc:

    • Patch Set #2, Line 114: // kernel32.dll used to be a good way to get a non-lying version number, but

      You still trust it for major/minor, though? Do those appear anywhere reliable in the registry?

    • Patch Set #2, Line 116:

      Therefore the
      // recommended way to get the os_version_bugfix_ and os_version_build_
      // numbers.

      I think this sentence is missing something, like “the registry”?

    • Patch Set #2, Line 120: if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) {

      80 columns (git cl format?)

      Also on lines 127 and 139.

    • Patch Set #2, Line 120: L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"

      Does this key (and the two values you’re looking up) exist and is it reliable as far back as our minimum supported Windows version?

    • Patch Set #2, Line 123: {

      Extra {scope} doesn’t seem necessary. Same on line 135.

    • Since you’re expecting an unsigned, size this at [11] and let RegQueryValueEx return an error if the value doesn’t fit.

    • Patch Set #2, Line 130: if (swscanf(reg_build_number, L"%u", &current_build_number) == 1)

      #include "util/stdlib/string_number_conversion.h" and use StringToNumber instead.

    • Patch Set #2, Line 131: os_version_bugfix_ = current_build_number;

      Since the stuff above was sorted most-to-least significant, putting os_version_build_ before os_version_bugfix_, I think this should follow suit.

    • Patch Set #2, Line 139: if (RegQueryValueEx(key, L"UBR", nullptr, &type, reinterpret_cast<BYTE*>(&reg_ubr), &size2) == ERROR_SUCCESS &&

      Can you expand “UBR” in a comment?

    • Patch Set #2, Line 141: os_version_build_ = base::StringPrintf("%lu", reg_ubr);

      Funny, the thing we wanted as a number came as REG_SZ, and the thing we wanted as a string came as REG_DWORD. :)

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 2
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-CC: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Bruce Dawson <bruce...@chromium.org>
Gerrit-Comment-Date: Tue, 08 Feb 2022 20:54:09 +0000

Bruce Dawson (Gerrit)

unread,
Feb 8, 2022, 7:59:14 PM2/8/22
to Mark Mentovai, Joshua Peraza, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Joshua Peraza, Mark Mentovai.

View Change

13 comments:

  • Patchset:

    • Patch Set #3:

      Okay, patch updated. Three issues are responded to without necessarily being finished, so comments are appreciated.

  • File snapshot/win/system_snapshot_win.cc:

    • Patch Set #2, Line 114: // kernel32.dll used to be a good way to get a non-lying version number, but

      You still trust it for major/minor, though? Do those appear anywhere reliable in the registry?

    • That is the obvious question: should we get all of it from the registry? In that registry directory we have:

      CurrentMajorVersionNumber.CurrentMinorVersionNumber.CurrentBuildNumber.UBR

      So, yes, it is all available, on Windows 10. These are all stored as REG_DWORD except for CurrentBuildNumber - odd.

      However the first two numbers are not in the registry in that form on Windows 7, so sticking with kernel32.dll to get them makes sense, I think.

    • Patch Set #2, Line 116:

      Therefore the
      // recommended way to get the os_version_bugfix_ and os_version_build_
      // numbers.

      I think this sentence is missing something, like “the registry”?

    • Done

    • Done

    • Patch Set #2, Line 120: if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) {

    • 80 columns (git cl format?) […]

      Whoops! I'm so used to the "git cl upload" format reminders that I completely depend on them, and I didn't get one from the crashpad repo. Fixed.

    • Patch Set #2, Line 120: = ERROR_SUCCESS) {

      needs formatting

      Done

    • Does this key (and the two values you’re looking up) exist and is it reliable as far back as our min […]

      Excellent question. I just checked on Windows 7 and it has CurrentBuildNumber and UBR, but it lacks the other two. The odd thing is that UBR is 24136 in the registry, but kernel32.dll (64-bit version) is 6.1.7601.24384. That is, in this case kernel32.dll is more recent than what the registry says. winver doesn't list the last version number in this case, it just says "Version 6.1 (Build 7601: Service Pack 1)"

      In this case of Windows 7 the motivating issue (kernel32.dll not being updated on all updates) is less likely so we could skip the registry reads on Windows 7, or take the larger of the two numbers. I think max() makes sense.

    • I put the extra scope in because while experimenting with this it was easy to accidentally pass the wrong variable address, and that problem goes away with the scopes. That said, I'll remove them since they aren't as important once the code is working.

    • Since you’re expecting an unsigned, size this at [11] and let RegQueryValueEx return an error if the […]

      Done

    • wchar_t reg_build_number[100];


    • DWORD type;
      DWORD size = sizeof(reg_build_number);
      if (RegQueryValueEx(key, L"CurrentBuildNumber", nullptr, &type, reinterpret_cast<BYTE*>(&reg_build_number), &size) == ERROR_SUCCESS &&
      type == REG_SZ) {
      unsigned current_build_number;
      if (swscanf

    • Documentation suggests ReqQueryValueEx() doesn't guarantee null-termination: https://docs.microsoft. […]

      Done

    • Patch Set #2, Line 130: if (swscanf(reg_build_number, L"%u", &current_build_number) == 1)

      #include "util/stdlib/string_number_conversion.h" and use StringToNumber instead.

    • It turns out this is messy because RegQueryValueEx returns WCHAR data and StringToNumber wants char. RegQueryValueExA works, but it feels like choosing between two imperfect solutions. This patch has both options, with #ifdefs. Opinions welcomed.

    • Since the stuff above was sorted most-to-least significant, putting os_version_build_ before os_vers […]

      os_version_build_ is the least significant, so the order is correct I believe.

    • Patch Set #2, Line 139: if (RegQueryValueEx(key, L"UBR", nullptr, &type, reinterpret_cast<BYTE*>(&reg_ubr), &size2) == ERROR_SUCCESS &&

      Can you expand “UBR” in a comment?

    • Apparently it us Update Build Revision. Go figure.

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 3
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-CC: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Joshua Peraza <jpe...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Wed, 09 Feb 2022 00:58:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Joshua Peraza <jpe...@chromium.org>
Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
Gerrit-MessageType: comment

Mark Mentovai (Gerrit)

unread,
Feb 9, 2022, 10:12:07 AM2/9/22
to Bruce Dawson, Joshua Peraza, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Joshua Peraza, Bruce Dawson.

View Change

9 comments:

    • That is the obvious question: should we get all of it from the registry? In that registry directory we have:

    • CurrentMajorVersionNumber.CurrentMinorVersionNumber.CurrentBuildNumber.UBR

      So, yes, it is all available, on Windows 10. These are all stored as REG_DWORD except for CurrentBuildNumber - odd.

      However the first two numbers are not in the registry in that form on Windows 7, so sticking with kernel32.dll to get them makes sense, I think.

    • Excellent question. I just checked on Windows 7 and it has CurrentBuildNumber and UBR, but it lacks the other two. The odd thing is that UBR is 24136 in the registry, but kernel32.dll (64-bit version) is 6.1.7601.24384. That is, in this case kernel32.dll is more recent than what the registry says. winver doesn't list the last version number in this case, it just says "Version 6.1 (Build 7601: Service Pack 1)"

    • In this case of Windows 7 the motivating issue (kernel32.dll not being updated on all updates) is less likely so we could skip the registry reads on Windows 7, or take the larger of the two numbers. I think max() makes sense.

    • At first, max seems somewhat reasonable, but specifically, how? Max of each component? Probably wrong on its face. Max of, in effect, the 128-bit number created by merging all four components? Seems more right. Actually, I think both may be wrong. In light of your thread at https://groups.google.com/a/google.com/g/chrome-stability/c/vSARwM5KVt0 and my response, I wonder: what happens if you experience the “Windows 10 problem” and the “Windows 11 problem” simultaneously? It seems that the kernel32.dll version number has only a loose connection to reality for at least two reasons now. Maybe it’s better to not consult it at all when something more authoritative exists.

    • It turns out this is messy because RegQueryValueEx returns WCHAR data and StringToNumber wants char. RegQueryValueExA works, but it feels like choosing between two imperfect solutions. This patch has both options, with #ifdefs. Opinions welcomed.

      Ooh, I don’t like either of those! I guess I have a slight preference for RegQueryValueExA, but between these two, it’s not so strong that I’d insist. Your call.

    • os_version_build_ is the least significant, so the order is correct I believe.

      Yes, I must have misread.

  • File snapshot/win/system_snapshot_win.cc:

    • Patch Set #3, Line 147: type == REG_SZ) {

      As you point out: weird that this isn’t REG_DWORD! Are we “confident” that this will remain REG_SZ? As in, are others relying on this to the point that Microsoft’s probably bound to leave it alone?

    • Patch Set #3, Line 149: reg_build_number[size / sizeof(reg_build_number[0])] = 0;

      We like char literals to be typed in this code, so if you’re using the char form, use `'\0'`, and if wchar_t, `L'\0'`.

    • Patch Set #3, Line 160: DWORD size2 = sizeof(reg_ubr);

      You don’t need a new variable for this, you can recycle `size`.

    • Patch Set #3, Line 170:

      On Windows 10 and above it is common for a monthly update to ship,
      // thus increasing the value of the UBR key, without updating
      // kernel32.dll

      Based on your description, I thought that this form of the problem applied to Windows 11, not Windows 10.

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 3
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Joshua Peraza <jpe...@chromium.org>
Gerrit-Attention: Bruce Dawson <bruce...@chromium.org>
Gerrit-Comment-Date: Wed, 09 Feb 2022 15:12:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Bruce Dawson <bruce...@chromium.org>

Bruce Dawson (Gerrit)

unread,
Feb 9, 2022, 11:38:25 AM2/9/22
to Mark Mentovai, Joshua Peraza, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Joshua Peraza, Mark Mentovai.

View Change

3 comments:

  • File snapshot/win/system_snapshot_win.cc:

    • > That is the obvious question: should we get all of it from the registry? In that registry director […]

      I think that makes a lot of sense. I'll do that.

  • File snapshot/win/system_snapshot_win.cc:

    • As you point out: weird that this isn’t REG_DWORD! Are we “confident” that this will remain REG_SZ? […]

      I'm pretty confident, but ultimately predicting the future is difficult. If they change this then we'll find out about it quickly enough.

    • Patch Set #3, Line 170:

      On Windows 10 and above it is common for a monthly update to ship,
      // thus increasing the value of the UBR key, without updating
      // kernel32.dll

    • Based on your description, I thought that this form of the problem applied to Windows 11, not Window […]

      I think that in theory it could happen on Windows 10. I don't know if it has happened in practice. I'll word-smith the comment a bit.

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 3
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Joshua Peraza <jpe...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Wed, 09 Feb 2022 16:38:19 +0000

Bruce Dawson (Gerrit)

unread,
Feb 9, 2022, 1:04:38 PM2/9/22
to Mark Mentovai, Joshua Peraza, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Joshua Peraza, Mark Mentovai.

View Change

8 comments:

  • Patchset:

    • Patch Set #4:

      After a productive discussion I think the code is in good shape now. PTAL.

  • File snapshot/win/system_snapshot_win.cc:

    • I think that makes a lot of sense. I'll do that.

      Done

    • > Excellent question. […]

      Now that I've switched to getting version information from either the registry _or_ kernel32.dll this issue goes away.

    • > It turns out this is messy because RegQueryValueEx returns WCHAR data and StringToNumber wants cha […]

      Done

  • File snapshot/win/system_snapshot_win.cc:

    • I'm pretty confident, but ultimately predicting the future is difficult. […]

      Done

    • We like char literals to be typed in this code, so if you’re using the char form, use `'\0'`, and if […]

      Done

    • Patch Set #3, Line 160: DWORD size2 = sizeof(reg_ubr);

      You don’t need a new variable for this, you can recycle `size`.

    • Done

    • Patch Set #3, Line 170:

      On Windows 10 and above it is common for a monthly update to ship,
      // thus increasing the value of the UBR key, without updating
      // kernel32.dll

    • I think that in theory it could happen on Windows 10. I don't know if it has happened in practice. […]

      The code got refactored enough that this comment disappeared, but the replacement should be fine.

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 4
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Joshua Peraza <jpe...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Wed, 09 Feb 2022 18:04:33 +0000

Joshua Peraza (Gerrit)

unread,
Feb 9, 2022, 1:55:20 PM2/9/22
to Bruce Dawson, Mark Mentovai, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Bruce Dawson, Mark Mentovai.

Patch set 5:Code-Review +1

View Change

1 comment:

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 5
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Bruce Dawson <bruce...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Wed, 09 Feb 2022 18:55:13 +0000

Mark Mentovai (Gerrit)

unread,
Feb 9, 2022, 2:19:54 PM2/9/22
to Bruce Dawson, Joshua Peraza, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Bruce Dawson.

View Change

6 comments:

  • File snapshot/win/system_snapshot_win.cc:

    • Patch Set #5, Line 75: bool ReadValueDW(HKEY key, const wchar_t* name, int* out_value) {

      Name this so that it’s clear at the call site that it’s talking to the registry, like ReadRegistryDWORD.

    • Patch Set #5, Line 123: as

      Strike “as” now.

    • Patch Set #5, Line 143: REGSZ

      REG_SZ

    • Patch Set #5, Line 152:

            char reg_build_number[11];
      DWORD type;
      // Leave space for a terminating zero.
      DWORD size = sizeof(reg_build_number) - sizeof(reg_build_number[0]);
      // Use the 'A' version of this function so that we can use
      // StringToNumber.
      if (RegQueryValueExA(key,


    • "CurrentBuildNumber",
      nullptr,
      &type,
      reinterpret_cast<BYTE*>(&reg_build_number),
      &size) == ERROR_SUCCESS &&
      type == REG_SZ) {

    •         // Make sure the string is null-terminated.
      reg_build_number[size / sizeof(reg_build_number[0])] = '\0';
      unsigned current_build_number;
      if (StringToNumber(reg_build_number, &current_build_number)) {

      Why don’t you refactor this whole thing into something like ReadRegistryDWORDFromSZ? Then you could write this whole thing as `bool version_data_found = Read(…) && Read(…) && Read(…) && Read(…);`.

    • Patch Set #5, Line 181:

          std::string flags_string = GetStringForFileFlags(ffi.dwFileFlags);
      std::string os_name = GetStringForFileOS(ffi.dwFileOS);

      Is there a registry source that we could use for these now too?

    • Patch Set #5, Line 190: %d

      %u to match what was here before and to match the way the rest will be formatted in the following statement.

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 5
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Bruce Dawson <bruce...@chromium.org>
Gerrit-Comment-Date: Wed, 09 Feb 2022 19:19:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Bruce Dawson (Gerrit)

unread,
Feb 9, 2022, 6:50:50 PM2/9/22
to Joshua Peraza, Mark Mentovai, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Mark Mentovai.

View Change

8 comments:

  • Patchset:

    • Patch Set #7:

      The CQ DRY RUN keeps failing and I'm not sure why - it seems unrelated. The error is in snapshot/win/end_to_end_test.py where the winext\uext.dll fails to load which then means that !peb is not available. It feels like an environmental issue. Any thoughts? Here is the relevant debug spew:

       Unable to add extension DLL: uext
      The call to LoadLibrary(ext) failed, Win32 error 0n2
      "The system cannot find the file specified."
      Please check your debugger configuration and/or network access.
      This dump file has an exception of interest stored in it.
      The stored exception information can be accessed via .ecxr.
      (e64.524): Access violation - code c0000005 (first/second chance not available)
      *** WARNING: Unable to verify checksum for ntdll.dll
      *** WARNING: Unable to verify checksum for KERNELBASE.dll
      eax=00000000 ebx=0096ec64 ecx=ff896b59 edx=00000000 esi=00000000 edi=0096eed0
      eip=779e205c esp=0096ec24 ebp=0096ec88 iopl=0 nv up ei pl nz na pe nc
      cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000206
      ntdll!NtDelayExecution+0xc:
      779e205c c20800 ret 8
      0:000> cdb: Reading initial command '!peb;q'
      The call to LoadLibrary(ext) failed, Win32 error 0n2
      "The system cannot find the file specified."
      Please check your debugger configuration and/or network access.
      No export peb found
      quit:
  • File snapshot/win/system_snapshot_win.cc:

    • Name this so that it’s clear at the call site that it’s talking to the registry, like ReadRegistryDW […]

      Done

    • Done, although I felt I needed to add "so" later in the sentence to make it work.

    • Done

    • Done

    • Patch Set #5, Line 152:

            char reg_build_number[11];
      DWORD type;
      // Leave space for a terminating zero.
      DWORD size = sizeof(reg_build_number) - sizeof(reg_build_number[0]);
      // Use the 'A' version of this function so that we can use
      // StringToNumber.
      if (RegQueryValueExA(key,
      "CurrentBuildNumber",
      nullptr,
      &type,
      reinterpret_cast<BYTE*>(&reg_build_number),
      &size) == ERROR_SUCCESS &&
      type == REG_SZ) {
      // Make sure the string is null-terminated.
      reg_build_number[size / sizeof(reg_build_number[0])] = '\0';
      unsigned current_build_number;
      if (StringToNumber(reg_build_number, &current_build_number)) {

    • Why don’t you refactor this whole thing into something like ReadRegistryDWORDFromSZ? Then you could […]

      Yeah, that does work better. It hadn't occurred to me to make a function that was called once, but it works very well.

    • Patch Set #5, Line 181:

          std::string flags_string = GetStringForFileFlags(ffi.dwFileFlags);
      std::string os_name = GetStringForFileOS(ffi.dwFileOS);

      Is there a registry source that we could use for these now too?

    • Not that I can find. However:
      dwFileFlags is typically zero, which converts to an empty string. It's not clear if we would lose much by hard-coding that.
      GetStringForFileOS is practically hard-coded to "Windows NT" - the only other option is "Unknown".

      So, I don't know if there is any value in the GetStringForFileFlags() function.

    • %u to match what was here before and to match the way the rest will be formatted in the following st […]

      Done

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 7
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Wed, 09 Feb 2022 23:50:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Joshua Peraza <jpe...@chromium.org>

Mark Mentovai (Gerrit)

unread,
Feb 10, 2022, 11:02:54 AM2/10/22
to Bruce Dawson, Joshua Peraza, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Bruce Dawson.

View Change

5 comments:

  • Patchset:

    • Patch Set #7:

      The CQ DRY RUN keeps failing and I'm not sure why - it seems unrelated. The error is in snapshot/win/end_to_end_test.py where the winext\uext.dll fails to load which then means that !peb is not available. It feels like an environmental issue. Any thoughts? Here is the relevant debug spew:

       Unable to add extension DLL: uext
      The call to LoadLibrary(ext) failed, Win32 error 0n2
      "The system cannot find the file specified."
      Please check your debugger configuration and/or network access.
      This dump file has an exception of interest stored in it.
      The stored exception information can be accessed via .ecxr.
      (e64.524): Access violation - code c0000005 (first/second chance not available)
      *** WARNING: Unable to verify checksum for ntdll.dll
      *** WARNING: Unable to verify checksum for KERNELBASE.dll
      eax=00000000 ebx=0096ec64 ecx=ff896b59 edx=00000000 esi=00000000 edi=0096eed0
      eip=779e205c esp=0096ec24 ebp=0096ec88 iopl=0 nv up ei pl nz na pe nc
      cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000206
      ntdll!NtDelayExecution+0xc:
      779e205c c20800 ret 8
      0:000> cdb: Reading initial command '!peb;q'
      The call to LoadLibrary(ext) failed, Win32 error 0n2
      "The system cannot find the file specified."
      Please check your debugger configuration and/or network access.
      No export peb found
      quit:
    •     std::string flags_string = GetStringForFileFlags(ffi.dwFileFlags);
      std::string os_name = GetStringForFileOS(ffi.dwFileOS);

    • Not that I can find. However:


    • dwFileFlags is typically zero, which converts to an empty string. It's not clear if we would lose much by hard-coding that.
      GetStringForFileOS is practically hard-coded to "Windows NT" - the only other option is "Unknown".

    • So, I don't know if there is any value in the GetStringForFileFlags() function.

    • OK to leave as-is then.

  • File snapshot/win/system_snapshot_win.cc:

    • Patch Set #7, Line 159: int os_version_build = 0;

      No need to initialize me, all codepaths should write to me before I’m read. Let me be a sanitizer error if someone mishandles.

    • Patch Set #7, Line 173:

          if (ReadRegistryDWORD(key, L"CurrentMajorVersionNumber", &os_version_major_) &&
      ReadRegistryDWORD(key, L"CurrentMinorVersionNumber", &os_version_minor_) &&

      git cl format one more time before submitting.

    • Patch Set #7, Line 175: ReadRegistryDWORDFromSZ(key, "CurrentBuildNumber", &os_version_build) &&

      `&os_version_bugfix_` for this one?

      This is confusing because now it’s called CurrentBuildNumber, but what we call build has moved to what’s now called “UBR”. And to think that we originally chose these names to match Windows nomenclature at the time!

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 7
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Bruce Dawson <bruce...@chromium.org>
Gerrit-Comment-Date: Thu, 10 Feb 2022 16:02:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Bruce Dawson <bruce...@chromium.org>

Bruce Dawson (Gerrit)

unread,
Feb 10, 2022, 12:08:28 PM2/10/22
to Joshua Peraza, Mark Mentovai, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Mark Mentovai.

Patch set 9:Commit-Queue +1

View Change

5 comments:

  • Patchset:

    • Patch Set #7:

      > The CQ DRY RUN keeps failing and I'm not sure why - it seems unrelated. […]

      Wow. That was really weird. I couldn't reproduce it locally because my Python environment wouldn't run that test script. I guess it was the bug that you noticed, but I totally don't understand how the symptoms ended up like that.

  • Patchset:

    • Patch Set #9:

      Thank you for your patience and for finding that last bug. PTAL.

  • File snapshot/win/system_snapshot_win.cc:

    • No need to initialize me, all codepaths should write to me before I’m read. […]

      The compiler insists on zero initialization, otherwise builds on the bots give this warning/error:

       C:\b\s\w\ir\x\w\crashpad\snapshot\win\system_snapshot_win.cc(198) : error C2220: the following warning is treated as an error
      C:\b\s\w\ir\x\w\crashpad\snapshot\win\system_snapshot_win.cc(198) : warning C4701: potentially uninitialized local variable 'os_version_build' used
    • Patch Set #7, Line 173:

          if (ReadRegistryDWORD(key, L"CurrentMajorVersionNumber", &os_version_major_) &&
      ReadRegistryDWORD(key, L"CurrentMinorVersionNumber", &os_version_minor_) &&

      git cl format one more time before submitting.

    • Done

    • `&os_version_bugfix_` for this one? […]

      Whoops! Wow. I totally missed that. Thanks.

      And yeah, the names are a mess. UBR, also known as QFE, also known as ???

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 9
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Thu, 10 Feb 2022 17:08:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

Mark Mentovai (Gerrit)

unread,
Feb 10, 2022, 12:36:38 PM2/10/22
to Bruce Dawson, Joshua Peraza, Crashpad LUCI CQ, crashp...@chromium.org

Attention is currently required from: Bruce Dawson.

Patch set 9:Code-Review +1

View Change

3 comments:

  • Commit Message:

    • Patch Set #9, Line 7: Get correct version info from registry

      Can you prefix this with win: before landing, so the extent of the impact is very obvious from the `--pretty=oneline` log?

  • Patchset:

    • Wow. That was really weird. I couldn't reproduce it locally because my Python environment wouldn't run that test script. I guess it was the bug that you noticed, but I totally don't understand how the symptoms ended up like that.

    • It’s reasonable for `!peb` to need to know the version of the OS that produced the minidump. It’s maybe also reasonable for it to throw its hands up in the air if that reported version is newer than anything it’s ever heard of, or if it doesn’t pass some sanity checking.

  • Patchset:

    • Patch Set #9:

      Thank you for your patience and for finding that last bug. PTAL.

    • Bugs found, bugs fixed! Happy to help.

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

Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: I9d6745084060f033cd54c56f832aed4ac163e6be
Gerrit-Change-Number: 3434090
Gerrit-PatchSet: 9
Gerrit-Owner: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Bruce Dawson <bruce...@chromium.org>
Gerrit-Reviewer: Joshua Peraza <jpe...@chromium.org>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Bruce Dawson <bruce...@chromium.org>
Gerrit-Comment-Date: Thu, 10 Feb 2022 17:36:33 +0000
Reply all
Reply to author
Forward
0 new messages