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

[ARM32] Exception filter failed to catch exception #5676

Closed
parjong opened this issue Apr 21, 2016 · 1 comment · Fixed by dotnet/coreclr#4503
Closed

[ARM32] Exception filter failed to catch exception #5676

parjong opened this issue Apr 21, 2016 · 1 comment · Fixed by dotnet/coreclr#4503
Assignees

Comments

@parjong
Copy link
Contributor

parjong commented Apr 21, 2016

It seems that exception filter does not work correctly on ARM32. Currently, running the following program results in unhandled exception error:

namespace ConsoleApplication { public class Program {

  public static void Main(string[] args) {
    try {
      throw new System.Exception("Throw");
    } catch (System.Exception e)  when ( true ) {
      System.Console.WriteLine("Hello World!");
    }
  }

} }

CoreCLR is expected to work as follows:

Hello World!

However, it currently shows the following output:

Unhandled Exception: System.Exception: Throw
   at ConsoleApplication.Program.Main(String[] args)
@parjong parjong changed the title [ARM32] Exception is not catched by filter. [ARM32] Exception filter failed to catch exception Apr 21, 2016
parjong referenced this issue in parjong/coreclr Apr 22, 2016
This commit revises legecy codegen to inserts a bkpt instruction if the current BB
and next BB is not in the same exception handling region.

This code is backported from ARM64 codegen.
@parjong
Copy link
Contributor Author

parjong commented Apr 22, 2016

It looks like that I found the reason why it fails.

Here is the code generated from JIT:

G_M31466_IG04:                                                                           
000046  BF00           nop
000048  F642 20CC      movw    r0, 0x2acc
00004C  F2C7 10D8      movt    r0, 0x71d8
000050  F245 5381      movw    r3, 0x5581
000054  F2C7 6347      movt    r3, 0x7647
000058  4798           blx     r3               // CORINFO_HELP_NEWSFAST
00005A  9005           str     r0, [sp+0x14]    // [V03 tmp0]
00005C  2001           movs    r0, 1
00005E  F644 217C      movw    r1, 0x4a7c
000062  F2C7 5195      movt    r1, 0x7595
000066  F246 0369      movw    r3, 0x6069
00006A  F2C7 6347      movt    r3, 0x7647
00006E  4798           blx     r3               // CORINFO_HELP_STRCNS
000070  9000           str     r0, [sp] // [V09 tmp6]
000072  9900           ldr     r1, [sp] // [V09 tmp6]
000074  9805           ldr     r0, [sp+0x14]    // [V03 tmp0]
000076  F246 0325      movw    r3, 0x6025
00007A  F2C7 13DD      movt    r3, 0x71dd
00007E  4798           blx     r3               // System.Exception:.ctor(ref):this
000080  9805           ldr     r0, [sp+0x14]    // [V03 tmp0]
000082  F24F 6355      movw    r3, 0xf655
000086  F2C7 6347      movt    r3, 0x7647
00008A  4798           blx     r3               // CORINFO_HELP_THROW

G_M31466_IG05:
00008C  BF00           nop

When CORINFO_HELP_TRHOW is called, PC will points to some instruction that corresponds to 00008C.

However, the exception handling region covers only for [0046..008C)

*************** EH table for ConsoleApplication.Program:Main(ref)
1 EH table entries, 0 duplicate clauses, 1 total EH entries reported to VM
EH#0: try [0046..008C) handled by [0104..013A) filter at [0096..0104)

Actually, this issue is already known and AMD64 and ARM64 codegen have a workaround. Unfortunately, it seems that this workaround is not applied to ARM32 codegen, yet.

chunseoklee referenced this issue in chunseoklee/coreclr Apr 26, 2016
This commit revises legecy codegen to inserts a bkpt instruction if the current BB
and next BB is not in the same exception handling region.

This code is backported from ARM64 codegen.
jkotas referenced this issue in dotnet/coreclr May 2, 2016
* Fix #4496

This commit revises legecy codegen to inserts a bkpt instruction if the current BB
and next BB is not in the same exception handling region.

This code is backported from ARM64 codegen.

* Update ControlPcIsUnwound in UnwindManagedExceptionPassX

* Enable only for ARM32

Enable the patch only for ARM32 in order to fix build break in other
architecture.
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant