Yes, the problem is happening for me because of pua_reginfo and I did 
https://github.com/linuxmaniac/kamailio/commit/2152b8c3ad4b1d61c4a456f7cb082ccfd10fe39c
 in order to solve it. But even with that I still get ucontac at shared mem 
left.

I'm suspecting that the underlying problem is the combination of 
get_static_urecord() + ul_callbacks + get_static_urecord(). The urecord is the 
same and it gets freed twice so only the first ucontact is free and the other 
is leaked.

see https://github.com/kamailio/kamailio/issues/997#issuecomment-280377848

REGISTER
```
Feb 16 17:04:43 sp1 proxy[9687]: NOTICE: <script>: New request on proxy - 
M=REGISTER R=sip:192.168.1.71 F=sip:43993005@192.168.1.71 
T=sip:43993005@192.168.1.71 IP=192.168.1.42:53152
 (127.0.0.1:5060) ID=8e40daa391b6e4d82b296c77eb0c6986@0.0.0.0 
UA='Jitsi2.9.5521Linux'
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:174]: 
get_static_urecord(): urecord static[0x7f7b41740200]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:142]: 
new_ucontact(): new ucontact[0x7f7b315f1d08]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:1155]: get_urecord(): 
DB_ONLY urecord[0x7f7b41740200]
```
``urecord static[0x7f7b41740200]`` is called before ul_callbacks and 
``ucontact[0x7f7b315f1d08]`` is created.

now pua_reginfo
```
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:174]: 
get_static_urecord(): urecord static[0x7f7b41740200]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:142]: 
new_ucontact(): new ucontact[0x7f7b315f24f8]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:142]: 
new_ucontact(): new ucontact[0x7f7b315f28f0]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:1155]: get_urecord(): 
DB_ONLY urecord[0x7f7b41740200]
```
 
``get_urecord()`` is called and the static ``urecord[0x7f7b41740200]`` is used 
and the new ``ucontact[0x7f7b315f28f0]`` and ``ucontact[0x7f7b315f24f8]`` are 
there.

This code has my fix so release_urecord() is called by pua_reginfo
```
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [urecord.c:553]: 
release_urecord(): free urecord[0x7f7b41740200]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:179]: 
free_ucontact(): free ucontact[0x7f7b315f24f8]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:179]: 
free_ucontact(): free ucontact[0x7f7b315f28f0]
```
and ``ucontact[0x7f7b315f28f0]`` and ``ucontact[0x7f7b315f24f8]`` are freed, 
perfect, but after the ul_callback now release_urecord() of the static 
``urecord[0x7f7b41740200]`` has no efect

```
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [urecord.c:553]: 
release_urecord(): free urecord[0x7f7b41740200]
```

so the initial ``ucontact[0x7f7b315f1d08]`` is not freed and the leak is done.

-- 
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/997#issuecomment-280596763
_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to