Unexpected call termination

I have some Asterisk servers, connected to CUCM 6.1.
All Asterisks have identical configuration and identical configuration of trunks in CUCM.
Two servers was updated to Asterisk 1.8.13.1~dfsg-1ubuntu2 version (from repositories) and then appeared the following error:
when call from Acterisk placed to CUCM, and remote side try to forward call or just hold, on asterisk call terminated.
Log of error when call hold used:
== Using SIP RTP CoS mark 5
– Executing [1164@local:1] Set(“SIP/4045-0000007a”, “SIP_CODEC=g729”) in new stack
– Executing [1164@local:2] Dial(“SIP/4045-0000007a”, “SIP/hq-trunk/1164”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/hq-trunk/1164
– SIP/hq-trunk-0000007b is ringing
– SIP/hq-trunk-0000007b answered SIP/4045-0000007a
[Nov 22 11:05:48] NOTICE[461]: chan_sip.c:6478 try_suggested_sip_codec: Changing codec to ‘g729’ for this call because of ${SIP_CODEC} variable
[Nov 22 11:05:48] NOTICE[461]: chan_sip.c:6478 try_suggested_sip_codec: Changing codec to ‘g729’ for this call because of ${SIP_CODEC} variable
– Remotely bridging SIP/4045-0000007a and SIP/hq-trunk-0000007b
[Nov 22 11:05:48] NOTICE[28172]: chan_sip.c:6478 try_suggested_sip_codec: Changing codec to ‘g729’ for this call because of ${SIP_CODEC} variable
[Nov 22 11:05:49] NOTICE[461]: chan_sip.c:6478 try_suggested_sip_codec: Changing codec to ‘g729’ for this call because of ${SIP_CODEC} variable
– Started music on hold, class ‘default’, on SIP/4045-0000007a
– Stopped music on hold on SIP/4045-0000007a
– Started music on hold, class ‘default’, on SIP/4045-0000007a
[Nov 22 11:05:49] WARNING[28172]: chan_sip.c:20412 handle_response_invite: just did sched_add waitid(937) for sip_reinvite_retry for dialog 59cffe6d4d19b2703f0b0faa18146f09@10.1.1.132:5060 in handle_response_invite
– Stopped music on hold on SIP/4045-0000007a
– Started music on hold, class ‘default’, on SIP/4045-0000007a
– Got SIP response 500 “Internal Server Error” back from 10.0.6.6:5060
== Spawn extension (local, 1164, 2) exited non-zero on ‘SIP/4045-0000007a’
– Stopped music on hold on SIP/4045-0000007a
[Nov 22 11:05:54] NOTICE[28172]: chan_sip.c:23072 handle_request_invite: Unable to create/find SIP channel for this INVITE
[Nov 22 11:05:54] NOTICE[28172]: chan_sip.c:23072 handle_request_invite: Unable to create/find SIP channel for this INVITE

Can someone can specify where to look or causes of what is happening?

sip.conf
[hq-trunk]
type=friend
context=hq
host=10.0.6.6
insecure=port,invite
disallow=all
allow=g729
phone
type=friend
context=local
host=dynamic
disallow=all
allow=alaw
allow=g729
4045 ; test

extensions.conf
[i][local]
; internal calls
exten => _40XX,1,Set(SIP_CODEC=alaw)
exten => _40XX,n,Dial(SIP/${EXTEN})
exten => _40XX,n,Hangup()

    ; calls to HQ
    exten => _XXXX,1,Set(SIP_CODEC=g729)
    exten => _XXXX,n,Dial(SIP/hq-trunk/${EXTEN})
    exten => _XXXX,n,Hangup()[/i]

The Cisco is claiming that its server is faulty. It is presumably broken for something related to re-invites. Having the full SIP trace will help understand the problem, but you could try disabling sendrpid, directmedia, and session timers, then turn them back on one at a time, if it starts working.