The test case involves sequential HTTP transfer with timeout period in between which should result in closing existing connection. Its using CURLOPT_SHARE and CURLDEBUG(debug build:--enable-debug --enable-curldebug).
Sequential HTTP transfers to complete without assertion.
Since the issue was seen in master, I could isolate it to 1 fix after 7.65.1 f67009d for the pull: #4013
To reproduce please use: 7.65.1 + 4013(as mentioned above), other latest from curl master can also be used.
As with debug build, there are assertions during CONN_LOCK and CONN_UNLOCK for double lock and lock/unlock without existing unlock/lock on same respectively.
After a lot of playing around, learnt that its when CURLOPT_SHARE is used along with debug build.
In this testcase flow its observed at connection is being locked during disconnection due to max age of the connection which is already holding the lock.
My little example maxage-conn.c seems to work as presumed both with and without the #4032 PR. I set the maximum age to one second and after a two second sleep the next transfer won't reuse the connection since it is now too old.