Fix the next_block attribute of the new block in ControlFlowGraph.split_block#170
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #170 +/- ##
=======================================
Coverage 95.43% 95.43%
=======================================
Files 7 7
Lines 2146 2147 +1
Branches 481 481
=======================================
+ Hits 2048 2049 +1
Misses 56 56
Partials 42 42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I will need a bit more time to double check things but this makes sense to me. Could you modify a test to enforce this ? |
|
Here you go, I've modified the few tests about the |
|
I forgot to mention this, but I found this potential bug because, for now, it's possible that a |
|
Indeed ! Note that the approach you describe is somewhat wrong since it is never the TryBegin that will cause the jump. |
|
Yes, you're right. When I said that the I was mainly making this comment because at first, I didn't notice that these instructions weren't necessarily at the end of the basic blocks as, in Python 3.10, their equivalent were the |
|
Could you describe a bit more what is your use case and what invariants you need the CFG to uphold ? |
|
Thanks for your answer. It does help me understand your use case. However it still seem somewhat backward to me since neither Since the existence of exception mean the execution can be interrupted at any block I do not see how to make a usable CFG that cwould only raise exception on the last instruction of a block. However there may be room to make it easier to figure out if instruction within a block are within an exception handling region. I will merge this shortly and release it as part of the next version which adds support for 3.14. |
|
Thank you! And no problem, as long as the |


Hi,
First of all, thank you for maintaining this library, it is really useful and complete!
I'm doing this little PR because while I was refactoring Pynguin's instrumentation component (se2p/pynguin#110), I encountered a small bug in the function
ControlFlowGraph.split_block. When splitting aBasicBlock, I think that thenext_blockattribute of the newly created block should be assigned to the previousnext_blockattribute, but it is not.If I'm not mistaken, the execution of the function should produce this result:
Input:
BasicBlock1.next_block=BasicBlock2Expected result:
BasicBlock1.next_block=BasicBlock3BasicBlock3.next_block=BasicBlock2However, it produces this result instead:
Actual result:
BasicBlock1.next_block=BasicBlock3BasicBlock3.next_block=NoneIs this a bug, or is it expected behaviour?
Thank you in advance, and have a nice day!