Skip to content

Commit

Permalink
[x86/Linux] Fix "Bad opcode" assert in unwindLazyState (dotnet/corecl…
Browse files Browse the repository at this point in the history
…r#8609)

* [x86/Linux] Fix "Bad opcode" assert in unwindLazyState

This commit suppresses "Bad opcode" assert while runing "Hello, World" example.

This commit address the following three code patterns discovered while
digging the assert failure:
 - and $0x1, %al
 - xor $0xff, %al
 - stack protection code:
   mov %gs:<off>, <reg>
   cmp <off>(%esp), <reg>
   mov <reg>, <off>($esp)
   jne <disp32>

This commit revises LazyMachState::unwindLazyState to handle the first two patterns,
and revises compile options not to emit the third pattern.

Commit migrated from dotnet/coreclr@2a7f2ff
  • Loading branch information
parjong authored and jkotas committed Dec 14, 2016
1 parent 97e9c5d commit d54ad36
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/coreclr/compileoptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ if (CLR_CMAKE_PLATFORM_UNIX)
# We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2)
add_compile_options(-fstack-protector)
else()
add_compile_options(-fstack-protector-strong)
if(NOT CLR_CMAKE_PLATFORM_ARCH_I386)
# x86 unwinder cannot handle stack protection code, yet
# see https://github.com/dotnet/coreclr/issues/8625 for details
add_compile_options(-fstack-protector-strong)
endif(NOT CLR_CMAKE_PLATFORM_ARCH_I386)
endif(CLR_CMAKE_PLATFORM_DARWIN)

add_definitions(-DDISABLE_CONTRACTS)
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/src/vm/i386/gmsx86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState,
ip += 2;
break;

case 0x34: // XOR AL, imm8
ip += 2;
break;

case 0x31:
case 0x32:
case 0x33:
Expand Down Expand Up @@ -879,6 +883,10 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState,
datasize = b16bit?2:4;
goto decodeRM;

case 0x24: // AND AL, imm8
ip += 2;
break;

case 0x01: // ADD mod/rm
case 0x03:
case 0x29: // SUB mod/rm
Expand Down

0 comments on commit d54ad36

Please sign in to comment.