Skip to content

Commit a25a4b8

Browse files
committed
[clr-interp] Fail with a BADCODE if the opcode is unknown
- Fail with BADCODE instead of asserting, which allows us to complete running some of the test suites, and will actually do the desired thing in actual retail builds. - Also protect against unsafe memory access by bounds checking in CEEOpName
1 parent ace4f36 commit a25a4b8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/coreclr/interpreter/compiler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ bool IsInterpDumpActive()
5959

6060
void AssertOpCodeNotImplemented(const uint8_t *ip, size_t offset)
6161
{
62+
#ifdef DEBUG
6263
fprintf(stderr, "IL_%04x %-10s - opcode not supported yet\n",
6364
(int32_t)(offset),
6465
CEEOpName(CEEDecodeOpcode(&ip)));
65-
assert(!"opcode not implemented");
66+
#endif // DEBUG
67+
BADCODE("opcode not implemented");
6668
}
6769

6870
// GCInfoEncoder needs an IAllocator implementation. This is a simple one that forwards to the Compiler.
@@ -4485,8 +4487,7 @@ void InterpCompiler::EmitStaticFieldAddress(CORINFO_FIELD_INFO *pFieldInfo, CORI
44854487
break;
44864488
}
44874489
default:
4488-
// TODO
4489-
assert(!"Unsupported (yet) static field accessor");
4490+
BADCODE("Unsupported static field accessor");
44904491
break;
44914492
}
44924493

src/coreclr/interpreter/intops.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ const uint32_t g_CEEOpNameOffsets[] = {
9696

9797
const char* CEEOpName(OPCODE op)
9898
{
99+
if (op >= (sizeof(g_CEEOpNameOffsets) / sizeof(g_CEEOpNameOffsets[0])))
100+
return "unused";
99101
return ((const char*)&g_CEEOpNameCharacters) + g_CEEOpNameOffsets[op];
100102
}
101103

0 commit comments

Comments
 (0)