Hi Daniel,
Could you please have a look at the following commit: 0bde3ca506467008cf3d8345afa731617b095c8c? I compiled Kamailio with the latest 5.4 branch (d43872c11edacf972c2ae72c746517dcf56e2777), excepting this commit - and it didn't crash for about 5 days already.