The first law of thermodynamics says the change in internal energy of a closed system is equal to the amount of heat supplied to the system, minus the amount of work done by the system on its surroundings. Mathematically:
$$\Delta U=Q-W$$
For a system undergoing a quasistatic process, we thus have
$$dU=\delta Q-PdV$$
where $P$ is the pressure of the system and $dV$ is the chance in volume of the system.
The first law is also sometimes written
$$\Delta U=Q+W$$
where this time $W$ is the work done by the surroundings on the system. We thus have
$$dU=\delta Q-P_\text{ext} dV$$
where $P_\text{ext}$ is the pressure exerted on the system by the surroundings.
If the two statements of the fist law are equivalent, then we should have that P_ext=P, but this is only true if the process is reversible.
So what is the error in my reasoning?
After all, by newton's third law, it should hold that the work done by the system on it's surroundings is equal to negative of the work done by the surroundings on the system (since a force applied by the surroundings on system accompanies a force of the same magntidude and in the opposite direction applied by system on surroundings).