Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

[Release/2.1] Fix intermittent segfaults in System.Xml.Linq.Events.Tests (#17851) #18199

Merged
merged 2 commits into from
May 31, 2018
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
#include <unistd.h> // sysconf
#include "globals.h"

#if defined(_ARM_) || defined(_ARM64_)
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF
#else
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN
#endif

// The cachced number of logical CPUs observed.
static uint32_t g_logicalCpuCount = 0;

Expand Down Expand Up @@ -67,7 +73,7 @@ bool GCToOSInterface::Initialize()
g_pageSizeUnixInl = uint32_t((pageSize > 0) ? pageSize : 0x1000);

// Calculate and cache the number of processors on this machine
int cpuCount = sysconf(_SC_NPROCESSORS_ONLN);
int cpuCount = sysconf(SYSCONF_GET_NUMPROCS);
if (cpuCount == -1)
{
return false;
Expand Down
12 changes: 10 additions & 2 deletions src/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,18 @@ PAL_GetLogicalCpuCountFromOS()
int nrcpus = 0;

#if HAVE_SYSCONF
nrcpus = sysconf(_SC_NPROCESSORS_ONLN);

#if defined(_ARM_) || defined(_ARM64_)
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF
#define SYSCONF_GET_NUMPROCS_NAME "_SC_NPROCESSORS_CONF"
#else
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN
#define SYSCONF_GET_NUMPROCS_NAME "_SC_NPROCESSORS_ONLN"
#endif
nrcpus = sysconf(SYSCONF_GET_NUMPROCS);
if (nrcpus < 1)
{
ASSERT("sysconf failed for _SC_NPROCESSORS_ONLN (%d)\n", errno);
ASSERT("sysconf failed for %s (%d)\n", SYSCONF_GET_NUMPROCS_NAME, errno);
}
#elif HAVE_SYSCTL
int rc;
Expand Down
9 changes: 8 additions & 1 deletion src/vm/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,11 +879,18 @@ void GCToEEInterface::StompWriteBarrier(WriteBarrierParameters* args)
g_lowest_address = args->lowest_address;
VolatileStore(&g_highest_address, args->highest_address);

#if defined(_ARM64_)
#if defined(_ARM64_) || defined(_ARM_)
// Need to reupdate for changes to g_highest_address g_lowest_address
is_runtime_suspended = (stompWBCompleteActions & SWB_EE_RESTART) || args->is_runtime_suspended;
stompWBCompleteActions |= ::StompWriteBarrierResize(is_runtime_suspended, args->requires_upper_bounds_check);

#ifdef _ARM_
if (stompWBCompleteActions & SWB_ICACHE_FLUSH)
{
::FlushWriteBarrierInstructionCache();
}
#endif

is_runtime_suspended = (stompWBCompleteActions & SWB_EE_RESTART) || args->is_runtime_suspended;
if(!is_runtime_suspended)
{
Expand Down