dotdotpan / exceptions4c

Automatically exported from code.google.com/p/exceptions4c
0 stars 0 forks source link

Cannot have more than 16 try blocks caught in a row #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
By default when an exception is caught in e4c_hook, the frame counter 
e4c.frames is not decremented. Hence we cannot have more than E4C_MAX_FRAMES 
exceptions caught in a program. Then e4c_lite complains "Too many `try` blocks 
nested" and exits, even if there is no nested try blocks at all.

If that behavior isn't on purpose, I believe the attached patch will fix it.

Original issue reported on code.google.com by fish.t...@gmail.com on 3 Feb 2015 at 7:45

Attachments:

GoogleCodeExporter commented 9 years ago
The frame counter must be decremented when the `try-catch-finally` block 
finishes. We cannot do that when an exception is caught, because we still must 
execute the `finally` block, if present.

I don't understand what you mean by "there is no nested try blocks at all". 
Could you provide an example of a program that has no nested try blocks and yet 
complains "Too many `try` blocks nested"?

Thank you.

Original comment by guillermocalvo on 3 Feb 2015 at 8:17

GoogleCodeExporter commented 9 years ago
Sorry, my bad. The real cause was that I directly exited the current function 
in my catch block, thus e4c_hook function is not executed after that and 
e4c.frames is not properly decremented.

I have attached a code snippet to trigger the problem.

The real solution, as I see it, would be not returning inside try/catch/finally 
blocks.

Thank you for this awesome project!

Original comment by fish.t...@gmail.com on 3 Feb 2015 at 5:25

Attachments: