fixed lock management in recording logic that randomly caused crash
The lock where acquired and released in each call, causing not clear behaviour and relative crashes, now should be more stable on this set of crashes, even though i did reproduce other crashes