Skip to content

Comments

feat: Add os context to events automatically#467

Merged
Swatinem merged 9 commits intomasterfrom
feat/os-context
Feb 3, 2021
Merged

feat: Add os context to events automatically#467
Swatinem merged 9 commits intomasterfrom
feat/os-context

Conversation

@Swatinem
Copy link
Contributor

@Swatinem Swatinem commented Jan 26, 2021

This captures OS context for the major OS (windows, macos, linux).

Q:

  • for macOS big sur, it gives version: 11.1, should I append a trailing .0 if the patch version is missing?
  • for linux/android, an example version is 5.4.61-android11-0-00791-gbad091cc4bf3-ab6833933, should I split that off into a build identifier rather?

@Swatinem Swatinem requested a review from a team January 27, 2021 13:31
@Swatinem Swatinem marked this pull request as ready for review January 27, 2021 13:36
@Mixaill
Copy link
Contributor

Mixaill commented Jan 28, 2021

By the way, maybe is it worth for Linux to parse /etc/*-release to get info about distro?

@Swatinem
Copy link
Contributor Author

@Mixaill I agree that the linux kernel version on its own has little meaning, however this is consistent with the information we can extract from breakpad/crashpad minidumps.

@jan-auer
Copy link
Member

I've seen crashpad include a custom section with lsb-release and friends, so at least there would be a possibility to do this.
Generally, we do not have a good answer for how to report Linux consistently across platforms. In Electron, we parse these files, but on any other platform I'm aware of we do not.

@Swatinem
Copy link
Contributor Author

@flub uname gives the following:

uts.release: 5.10.6-arch1-1
uts.version: #1 SMP PREEMPT Sat, 09 Jan 2021 18:22:35 +0000

The version part is pretty useless IMO.


void *ffibuf = NULL;

DWORD size = GetFileVersionInfoSizeW(L"kernel32.dll", NULL);
Copy link
Contributor

@Mixaill Mixaill Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why kernel32.dll version is used instead of GetVersionExW()?
Libraries versions does not match the Windows build version.

image

(yeah, there is popular advice in the internet to use kernel32.dll but it is not correct)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I copied whatever crashpad is doing, to be consistent with those tools. I was a bit surprised myself that the version does not reflect the 20H2 release number.

I will discuss this internally.

Copy link
Contributor

@Mixaill Mixaill Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you can use values from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion (that's what winver.exe actually use)

  • Version: <CurrentMajorVersionNumber>.<CurrentMinorVersionNumber>
  • Full Build: <CurrentMajorVersionNumber>.<CurrentMinorVersionNumber>.<CurrentBuildNumber>.<UBR>
  • Edition: <EditionID>
  • Update name: <DisplayVersion>

Copy link
Contributor

@Mixaill Mixaill Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you can combine GetVersionExW and registry to detect if application is running under compatibility mode:

  • In case of compatibility mode, GetVersionExW returns target version, not the real one)
  • In case of missing supportedOS field in application manifest, GetVersionExW returns 6.2 instead of 10.0

@Swatinem Swatinem merged commit d5848de into master Feb 3, 2021
@Swatinem Swatinem deleted the feat/os-context branch February 3, 2021 10:43
@Mixaill
Copy link
Contributor

Mixaill commented Feb 3, 2021

@Swatinem any further work is planned in a short time or can I improve behavior of Windows version detection?

@Swatinem
Copy link
Contributor Author

Swatinem commented Feb 3, 2021

any further work is planned in a short time

Well, I call this solved from my end.

The thing is that I built this to have the same behavior as crashpad. They also have a comment related to this here:

https://github.com/getsentry/crashpad/blob/cb520bd41fdea18a4d842efabeac61a2a5beaa61/snapshot
/win/system_snapshot_win.cc#L92-L112

There should be a compelling reason to deviate from that. I haven’t looked at the specific code in breakpad yet, but I expect it to do something similar.

@Swatinem
Copy link
Contributor Author

Swatinem commented Feb 3, 2021

Breakpad is using windbg APIs for this: https://docs.microsoft.com/en-us/windows/win32/api/minidumpapiset/nf-minidumpapiset-minidumpwritedump

I will see what that gives me in terms on windows version…

@Swatinem
Copy link
Contributor Author

Swatinem commented Feb 4, 2021

So that minidump gives me 10.0.19042 as the OS version, but honestly I don’t think its worth putting too much effort into this.

@Mixaill
Copy link
Contributor

Mixaill commented Feb 4, 2021

But, in any case, if I provide PR improvements in this area, will they be accepted or reviewed at least?

@Swatinem
Copy link
Contributor Author

Swatinem commented Feb 4, 2021

@jan-auer was a bit hesitant, maybe you can elaborate your concerns a bit more?

I have no objections if its equally well supported and a clear improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants