Bug #10567
same buffer can be used as argument multiple times
100%
Related issues
History
#2 Updated by Constantin Asofiei 10 months ago
- Related to Bug #10483: memory leak in BufferManager.openBuffers added
#3 Updated by Constantin Asofiei 10 months ago
- Priority changed from Normal to High
- Assignee set to Stefanel Pezamosca
We need to investigate the implications of this:
def temp-table tt1 field f1 as int. def buffer b1 for tt1. procedure proc0. def parameter buffer rb1 for tt1. def parameter buffer rb2 for tt1. message buffer rb1:handle buffer rb2:handle. // same handle end. run proc0(buffer b1, buffer b1).
In #10483, it was found that FWD (wrongly) managed to open the scope for the same buffer instance, when calling the 'execute' methods for the class and super-classes (as a buffer from a super-class had its scope open emitted by conversion both in super and sub-classes, as it was used).
In the test above, using the logging added by #10483, it was found that a buffer can be used as argument multiple times for the same call.
We need to find the implications of this.
For now, changing ScopedList to avoid re-registering the same element prevents breaking the openBuffers dictionary:
=== modified file 'src/com/goldencode/p2j/util/ScopedList.java'
--- old/src/com/goldencode/p2j/util/ScopedList.java 2025-08-28 14:34:28 +0000
+++ new/src/com/goldencode/p2j/util/ScopedList.java 2025-09-14 13:18:48 +0000
@@ -243,6 +243,11 @@
public void addAt(int depth, E element)
{
NodeList scope = getScopeAtDepth(depth);
+ if (scope.valueToNodes.containsKey(element))
+ {
+ // already registered
+ return;
+ }
Node<E> n = new Node<>(element);
if (size == 0)
But this does not solve other possible problems when the caller's buffer is bound to two or more parameter buffers at the callee, and what involves processing the scope at the callee multiple times for the same bound buffer.
Stefanel: please investigate this.
#4 Updated by Constantin Asofiei 10 months ago
10567a was created from trunk 16163.
Rev 16164 contains the ScopedList changes from #10483 and the patch above.
#5 Updated by Constantin Asofiei 10 months ago
- Assignee changed from Stefanel Pezamosca to Paul Bodale
#6 Updated by Constantin Asofiei 10 months ago
- Assignee changed from Paul Bodale to Teodor Gorghe
#7 Updated by Teodor Gorghe 10 months ago
I have looked on this task and I might have a solution.
I made an investigation on what happens right now:
- The BufferManager instance has private ScopedList<RB> instance, called openBuffers, which is a simply a list of NodeList, for every open block (??) scope.
- This ScopedList object also has a map which makes a correspondence between added element to the node element.
- The initial fix for this issue (#10567-3) is to check if the element is already to the current scope list.
- The issue with this fix is that the RB.openScope and BM.openScope still continues, incrementing other flags, like TxWrapper.count, openScopeCount, etc.
- When the openScope is called for the second time on the same buffer, in the same scope, this is not added in the finalizable list, which might make the RB.finished to be called only once.
Constantin, I am thinking about moving the logic that you have added on ScopedList.addAt to somewhere into ArgumentBuffer.invoke. There, I can obtain the BufferManager and do some checks before calling the openScope for the second time.
#8 Updated by Constantin Asofiei 10 months ago
Please keep the change in ScopedList (but still log a warning maybe). Otherwise, yes, find a place where we can avoid calling openScope twice.
#9 Updated by Teodor Gorghe 10 months ago
- % Done changed from 0 to 100
- Status changed from New to WIP
- reviewer Constantin Asofiei added
Committed revision 16165 on task branch 10567a:
- Avoid openScope call for the same buffer in the current scope.
Committed revision 16166 on task branch 10567a:
- Logging ScopeList.addAt when adding the same element more than twice.
#10 Updated by Teodor Gorghe 10 months ago
- Status changed from WIP to Review
#12 Updated by Alexandru Lungu 9 months ago
- Status changed from Review to Internal Test
I am OK with the changes in 10567a. they are cleaner than my attempt in #10818 in fact :)
#13 Updated by Alexandru Lungu 8 months ago
Teodor, is 10567a ready for trunk?
#14 Updated by Teodor Gorghe 8 months ago
All regression tests were done, but not for ChUI regression tests.
I am starting the tests right now and I think tomorrow I will have the results.
#15 Updated by Alexandru Lungu 8 months ago
- Status changed from Internal Test to Merge Pending
Feel free to skip ChUI regression tests and pair this branch testing with another task that requires ChUI regression testing in the future. I think he changes are too small to require independent ChUI testing.
Please merge 10567a to trunk now.
#16 Updated by Teodor Gorghe 8 months ago
ChUI regression testing passed, but I have forgot that I had included this into #10729 testing process.
Branch 10567a was merged to trunk rev. 16279 and archived.
#17 Updated by Alexandru Lungu 8 months ago
- Status changed from Merge Pending to Test