Skip to content

Commit 380d827

Browse files
committed
Fix fatal SEHException on Arm calling RDTSC
Arm does not have the x86 Timestamp Counter register or read timestamp counter instruction. Add an additional architecture check to prevent the code path when running on Arm.
1 parent 40504cd commit 380d827

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/NetMQ/Core/Utils/OpCode.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@ internal static class Opcode
1212

1313
public static bool Open()
1414
{
15+
#if NETSTANDARD1_1_OR_GREATER || NET471_OR_GREATER
16+
if (RuntimeInformation.ProcessArchitecture != Architecture.X86 &&
17+
RuntimeInformation.ProcessArchitecture != Architecture.X64)
18+
{
19+
return false; // RDTSC instruction not supported
20+
}
21+
#endif
22+
1523
var p = (int)Environment.OSVersion.Platform;
1624

1725
byte[] rdtscCode = IntPtr.Size == 4 ? RDTSC_32 : RDTSC_64;
1826

1927
s_size = (ulong)(rdtscCode.Length);
2028

21-
if ((p == 4) || (p == 128))
29+
if ((p == 4) || (p == 128)) // Unix || Mono on Unix
2230
{
2331
// Unix
2432
if (IsARMArchitecture()) return false;

0 commit comments

Comments
 (0)