Closed Dhairya-Sangoi closed 5 years ago
I will look into this tomorrow evening. I have to get some sleep now.
No worries. Thank you very much for the quick help :)
Hey, I was curious about how compiler creates state machine for async methods with try-catch. I looked on various forums but all I could get was how state machine is created for a normal async method. If you have any knowledge about this, could you please help me with it?
What do you mean with how it is created? As in the process of generating it or more the outcome of the generation?
Outcome of the generation. As in what is created when an async method with try-catch is converted to a state machine. Comparing it with the state machine generated for async methods with no try-catch, there seems to be some difference. And I was unable to find exact pattern as to what would a generic async method containing try-catch blocks be converted into.
Let me see I have still my notes somewhere... I had to analyse the way it is generated to be able to decide how to implement the interceptor...
That would help a lot in understanding what happens under the hood. I was initially trying to look for some patterns by decompiling different methods having slightly different bodies.But it seems the compiler does its optimizations, so I was unable to identify any logical pattern.
Hey, any updates on this bug?
This is the observation based on different types of async functions:
Outside try-catch-finally | Try | Catch | Finally | Failure |
---|---|---|---|---|
3 | 0 | 0 | 0 | 0 |
2 | 1 | 0 | 0 | 1 |
2 | 0 | 1 | 0 | 1 |
2 | 0 | 0 | 1 | 0 |
1 | 2 | 0 | 0 | 0 |
1 | 0 | 2 | 0 | 0 |
1 | 0 | 0 | 2 | 0 |
1 | 1 | 1 | 0 | 0 |
1 | 1 | 0 | 1 | 1 |
1 | 0 | 1 | 1 | 1 |
0 | 3 | 0 | 0 | 0 |
0 | 0 | 3 | 0 | 0 |
0 | 0 | 0 | 3 | 0 |
0 | 2 | 1 | 0 | 0 |
0 | 2 | 0 | 1 | 0 |
0 | 1 | 2 | 0 | 1 |
0 | 1 | 0 | 2 | 1 |
0 | 1 | 1 | 1 | 0 |
0 | 0 | 2 | 1 | 0 |
0 | 0 | 1 | 2 | 1 |
The numbers in the cell indicate the number of await calls in that scope. Value of 1 in failure column indicates that the function failed at runtime.
I tried to distribute 3 async calls in different scopes. I didn't experiment it with 4 or more async calls. But my assumption is, if it fails for a particular type of distribution, then adding an extra async call in any scope would also fail. Though, I am not sure if the distributions which are passing could fail when additional async calls are added to scopes.
I'll look into this asap… Thanks for the analysis. That helps me a lot.
Thanks!
Any luck with this?
Yap... Fix is coming... I just have to write unit test to insure that it never comes up again.
Firma: Capgemini Deutschland GmbH Aufsichtsratsvorsitzender: Antonio Schnieder • Geschäftsführer: Dr. Michael Schulte (Sprecher) • Jost Förster • Dr. Peter Lempp • Dr. Volkmar Varnhagen
Amtsgericht Berlin-Charlottenburg, HRB 98814 This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
Cool! Thanks for the update 👍
any update on when this will be available? really looking forward for this fix. thanks :)
Working on it right now... I am hoping to finish this today
Thanks for the fix!
Hey,
It seems there is a bug in weaving async methods.
Attribute:
Annotated class method:
Decompiled Weaved Code:
As it can be seen, the handling for state
0
:results in an infinite loop, if I understand correctly. Because this jumps to the label_0, which again sets
num1
with current state0
.Also,
This instruction
goto label_0;
is only weaved if there are multipleawaits
in thecatch
block.