SITUATION
Consider a very big cylinder with a mobile piston in the middle separating two sections (A and B) filled with gas. Both the cylinder walls and the piston are adiabatic, so there is no exchange of heat with the exterior or between sections. The pressure of the gas in A is much higher than the pressure of the gas in B (think 10 bar against 1 bar). The piston is originally being hold by one stick and there is another one not to far from it. We unlock the first and the system evolves until it hits the second one (we assume the change in volume was small enough so as to not produce any significant change of pressures: think 1 mL in total volumes of 1 L each section).
ANALYSIS
I first consider the change in energy of the total system in terms of the change of energy in the subsystems A and B. For the gas of section A, I could claim it only changed its $U$ by giving $p_B \Delta V$ of work to its environment (in this case, gas in section B). If I then consider the gas in section B, I can claim it received $p_A \Delta V$ of work from its environment (gas in section A). This $\Delta V$ is the same in magnitude for both cases but of opposite sign, so if I consider that the change in internal energy of the whole system must be the sum of these two, then I get:
$$ \Delta U_{tot} = \Delta U_{A} + \Delta U_{B} $$
$$ \Delta U_{tot} = -p_B \Delta V - p_A ( -\Delta V ) = ( p_A - p_B )\Delta V > 0 $$
However, if I then analyze what should happen to the whole system, it has not received any heat (adiabatic walls) nor any pressure work from the external environment (the external walls are fixed, the piston is an internal wall of the system). Since there is no other source of work being done to/by the system that I can identify, its $\Delta U_{tot}$ should be $0$.
What am I thinking wrong? Which step of the previous analysis is faulty? My intuition tells me that there is some "thermodynamically invisible" potential energy stored in the pressure difference between sections that is converted into "thermodynamically visible" energy by letting go of what is holding the piston, but (as my terminology indicates) I don't know how to consider this in thermodynamical terms.
Note 1: this question is similar to mine. But its author set the situation so that the change is infinitesimal in order to exchange the external pressure for the internal one in the work formula (as I understand it, $-p_{ext} \Delta V$ is valid for any process that is a constant external pressure). So as far as I can tell, the answer there heavily relies on this cuasi-static condition and doesn't really apply to this situation (or at least I don't understand how to adapt it). It is also mixing more "mechanical considerations" in ways I've never seen when dealing with a thermodynamic problem (like including the energy of the piston).
Note 2: I have previously stated this problem in another question. However, I did it in the context of a more general theoretical doubt and I think things got mixed up, so I ended up not quite satisfied with any response. I would like to avoid that here and just focus on understanding this problem, but just wanted to mention this to explain why I don't consider this to be a "double posting".