Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rid processing on macOS #60494

Merged
merged 5 commits into from
Oct 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions src/native/corehost/hostmisc/pal.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,26 +570,43 @@ pal::string_t pal::get_current_os_rid_platform()
char str[256];
size_t size = sizeof(str);

// returns something like 10.5.2
// returns something like 10.5.2 or 11.6
int ret = sysctlbyname("kern.osproductversion", str, &size, nullptr, 0);
if (ret == 0)
{
// the value _should_ be null terminated but let's make sure
str[size - 1] = 0;

char* pos = strchr(str, '.');
if (pos != NULL)
{
pos = strchr(pos + 1, '.');

if (pos != NULL)
int major = atoi(str);
if (major > 11)
{
// strip anything after second dot and return something like 10.5
// starting with 12.0 we track only major release
*pos = 0;
size = pos - str;

}
else if (major == 12)
Copy link

Choose a reason for hiding this comment

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

Shouldn't this read else if (major == 11)? I think line 594 will never execute because, if major==12, line 587 executes instead.

Copy link
Contributor

@AustinWise AustinWise Oct 20, 2021

Choose a reason for hiding this comment

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

I was thinking that too. Here is a PR to fix: #60668

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, this should not be there. It somehow sneaked in when I was trying to remove the extra size calculation ;(

{
// for 11.x we publish RID as 11.0
// if we return anything else, it would break the RID graph processing
strcpy(str, "11.0");
}
else
{
// for 10.x the significant releases are actually the second digit
pos = strchr(pos + 1, '.');

if (pos != NULL)
{
// strip anything after second dot and return something like 10.5
*pos = 0;
}
}
}

std::string release(str, size);
std::string release(str, strlen(str));
ridOS.append(_X("osx."));
ridOS.append(release);
}
Expand Down