### Description
IMS reregistration triggers core dump on 5.1.4.
1) Create IMS registration
2) Put IMS terminal offline
3) Put it back online to update IMS registration
4) Register requests time out on s-cscf
### Troubleshooting
This seems to be related to the cleaning up contacts during registration/re-registration.
Related to the
https://github.com/kamailio/kamailio/pull/1562. This PR did not make it to
5.1.4 but affected code was clearly involved according to the logs.
#### Reproduction
#### Debugging Data
#### Log Messages
```
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[impurecord.c:451]: process_impurecord(): There are 2 contacts to expire/unlink
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[impurecord.c:454]: process_impurecord(): expiring contact 0:
[sip:XXXYY4000013362@10.110.1
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[impurecord.c:1237]: unlink_contact_from_impu(): asked to unlink contact [0x7f7141cf29a0]
=> [sip:XXXYY4000
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[impurecord.c:1106]: remove_impucontact_from_list(): deleting mid list
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[usrloc_db.c:1130]: db_unlink_contact_from_impu(): DB: un-linking contact to IMPU
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: <core> [db_res.c:120]:
db_new_result(): allocate 56 bytes for result set at 0x7f714ba6e620
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: <core> [db_res.c:79]:
db_free_columns(): freeing 0 columns
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: <core> [db_res.c:138]:
db_free_result(): freeing result set at 0x7f714ba6e620
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[usrloc_db.c:1155]: db_unlink_contact_from_impu(): Delete query success
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf [udomain.c:852]:
unref_contact_unsafe(): decrementing ref count on contact
[sip:XXXYY4000013362@10.110.1.69
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf [udomain.c:855]:
unref_contact_unsafe(): contact
[sip:XXXYY4000013362@10.110.1.69:5060;alias=10.110.1.69~50
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[impurecord.c:1263]: unlink_contact_from_impu(): unlinking contact [0x7f7141cf29a0] =>
[sip:XXXYY4000013362
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[impurecord.c:454]: process_impurecord(): expiring contact 1:
[sip:XXXYY4000013362@10.110.1
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[impurecord.c:1237]: unlink_contact_from_impu(): asked to unlink contact [0x7f7141cfc878]
=> [sip:XXXYY4000
Jul 24 07:21:00 scscf scscfXXXYYY-ecs[798]: 1(6) DEBUG: ims_usrloc_scscf
[impurecord.c:1103]: remove_impucontact_from_list(): **deleting tail**
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: ims_registrar_scscf
[save.c:840]: update_contacts(): updating contacts in RE-REGISTRATION state
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: ims_registrar_scscf
[save.c:519]: update_contacts_helper(): updating the contacts for IMPU
<sip:XXXYY4000013362@ims.mnc006.
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: <core>
[ims_getters.c:812]: cscf_get_sos_uri_param(): cscf_get_sos_uri_param: searching through
the uri parameters:alias=10
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: <core>
[ims_getters.c:823]: cscf_get_sos_uri_param(): cscf_get_sos_uri_param:name: alias body:
10.110.1.71~5060~1
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: ims_registrar_scscf
[save.c:137]: calc_contact_expires(): Calculated expires for contact is 600000
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: ims_registrar_scscf
[save.c:548]: update_contacts_helper(): Need to update contact:
<sip:XXXYY4000013362@10.110.1.71:5060;a
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: ims_registrar_scscf
[save.c:550]: update_contacts_helper(): packing contact information
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: ims_registrar_scscf
[save.c:556]: update_contacts_helper(): adding/updating contact based on prior existence
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: ims_usrloc_scscf
[impurecord.c:748]: get_scontact(): looking for contact
[sip:XXXYY8000099992@10.110.1.71:5060;alias=10.110
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: ims_registrar_scscf
[save.c:562]: update_contacts_helper(): inserting new contact
Jul 24 07:22:21 scscf scscfXXXYYY-ecs[798]: 15(20) DEBUG: ims_usrloc_scscf
[impurecord.c:562]: insert_scontact(): INSERTing ucontact in usrloc module
Jul 24 07:22:21 scscf kernel: traps: kamailio[7186] general protection ip:7f7146511000
sp:7ffc9f3719a0 error:0 in ims_usrloc_scscf.so[7f71464e7000+8f000]
```
#### SIP Traffic
![image](https://user-images.githubusercontent.com/1636682/43138556-8dc89988-8f4f-11e8-887a-53c4fb7805e1.png)
```
(paste your sip traffic here)
```
### Possible Solutions
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.1.4 (x86_64/linux)
```
* **Operating System**:
```
Linux scscf 4.14.48-coreos-r2 #1 SMP Thu Jun 14 08:23:03 UTC 2018 x86_64 x86_64 x86_64
GNU/Linux
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1600