llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.98k stars 11.94k forks source link

Macro generated try-catch results in abortion of subsequent throw's... #41425

Open llvmbot opened 5 years ago

llvmbot commented 5 years ago
Bugzilla Link 42080
Version 7.0
OS Linux
Attachments crude testing example source
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@erichkeane,@zygoloid,@rnk

Extended Description

It seems that the code in a macro, such as this;

define EXCEPTION_ESCAPE_TRY(F, N) \

try { \ F; \ } catch (...) \ { \ printf("macro catch success"); \ printf(N); \ return -1; \ }

...will be stripped out of existence, for reasons unknown. Even under pedantic mode, passing a cc* to N will fail to trigger a warning or error, as it apparently "doesn't even exist".

'F;' will occur still however, but any throw's within will compile as abort(0)'s, even if the macro itself resides inside a parent try-catch. If the F; is replaced with a simple throw; the entire macro seems to vanish entirely...

A crude example source is attached, that tests each general try-catch case before the macro-generated one. All behaves as expected when jumping through the debugger, until you get to the macro where it simply abort's...

erichkeane commented 5 years ago

Executed on Godbolt's linux version doesn't seem to reproduce the reported issue:

https://godbolt.org/z/OQYkpE

rnk commented 5 years ago

I took your example, compiled it for linux, generated assembly, and we don't generate any calls to abort.

It is possible that we generate an incorrect LSDA, and therefore the EH runtime aborts. Unfortunately, my Linux machine is not online at the moment, so I can't actually execute your code to try to reproduce.