<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [x] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [x] PR should be backported to stable branches
- [x] Tested changes locally
#### Description
I was creating avp variables at route_event[usrloc:contact-expired] and shared memory was always growing I think this is the same issue #1391 and solved by ad46b115bedec01c52c5a9dcde0756db85ee61ec
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1994
-- Commit Summary --
* registrar: clean avp/xavp created at 'usrloc:contact-expired' route_event
-- File Changes --
M src/modules/registrar/regpv.c (3)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1994.patchhttps://github.com/kamailio/kamailio/pull/1994.diff
--
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/pull/1994
### Description
Investigating a report on a Kamailio crash, it led to pdb module, with the following backtrace:
```
#0 0x0000000000000000 in ?? ()
#1 0x00007f870472fa33 in vfprintf () from /lib64/libc.so.6
#2 0x00007f87047562bb in vsprintf () from /lib64/libc.so.6
#3 0x00007f8704738457 in sprintf () from /lib64/libc.so.6
#4 0x00007f86f881c6f9 in pdb_msg_dbg (msg=..., dbg_msg=0x7f86f8828313 "Kamailio pdb client receives:") at pdb.c:152
#5 0x00007f86f88204e4 in pdb_query (_msg=0x7f8700fae068, _number=0x7f8700fa2e88, _dstavp=0x7f8700fa2f10) at pdb.c:335
#6 0x000000000047b72c in do_action (h=0x7ffeb03d10e0, a=0x7f8700abf678, msg=0x7f8700fae068) at core/action.c:1079
#7 0x0000000000487e70 in run_actions (h=0x7ffeb03d10e0, a=0x7f8700abf678, msg=0x7f8700fae068) at core/action.c:1569
#8 0x0000000000488531 in run_actions_safe (h=0x7ffeb03d3180, a=0x7f8700abf678, msg=0x7f8700fae068) at core/action.c:1633
#9 0x0000000000447f40 in rval_get_int (h=0x7ffeb03d3180, msg=0x7f8700fae068, i=0x7ffeb03d18b0, rv=0x7f8700ac0148, cache=0x0) at core/rvalue.c:912
#10 0x000000000044c4f0 in rval_expr_eval_int (h=0x7ffeb03d3180, msg=0x7f8700fae068, res=0x7ffeb03d18b0, rve=0x7f8700ac0140) at core/rvalue.c:1910
```
Looking at the data in frame 4, it looks that an empty (0-ed) pdb structure is printed:
```
(gdb) frame 4
#4 0x00007f86f881c6f9 in pdb_msg_dbg (msg=..., dbg_msg=0x7f86f8828313 "Kamailio pdb client receives:") at pdb.c:152
152 ptr += sprintf(ptr,"%02X ", msg.bdy.payload[i]);
(gdb) p i
$1 = 263
(gdb) p msg
$2 = {hdr = {version = 0 '\000', type = 0 '\000', code = 0 '\000', length = 0 '\000', id = 0}, bdy = {payload = '\000' <repeats 248 times>}}
(gdb) p msg.hdr.length
$3 = 0 '\000'
```
I just pushed commit 3c07e2351a94e4ff2cf3c6b9b9df4d7462cd5760 for a safety check, but not being the developer of the module, I am not sure it is supposed to deal with a 0-ed pdb structure, or the issue is somewhere else, leading to this 0-only structure content.
Therefore I am opening this one for further analyze, if the commit above is enough, just close the issue.
### Troubleshooting
#### Reproduction
Try to send traffic to a config using pdb matching PDB_VERSION_1.
#### Debugging Data
```
gdb backtrace above
```
#### Log Messages
```
N/A
```
#### SIP Traffic
```
N/A
```
### Possible Solutions
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
kamailio -v
version: kamailio 5.2.3 (x86_64/linux) c36229
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: c36229
compiled on 10:34:54 Jun 13 2019 with gcc 4.8.5
```
* **Operating System**:
```
CentOS 7 with Kamailio installed from RPM (using opensuse build service repo)
```
--
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/1985
### Description
We noticed one of our kamailio instances using increasing amounts of pkg memory.
This appears to be related to the sanity-check module.
sanity.c:655 - `if (msg->proxy_require->parsed == NULL)` then that header is parsed into `msg->proxy_require->parsed`. This buffer should be free'd in sanity.c:712, but this only happens if the sanity check is succesfull. If the sanity check fails (on line 701), then the buffer is never free'd.
### Troubleshooting
#### Reproduction
We can reproduce the issue by repeatedly sending the following SIP packet to kamailio.
Please note that this 'Proxy-Require' header is invalid in our setup, and is most likely originally caused by an invalid configured phone.
```
SUBSCRIBE sip:phone_0@example.com:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.102:5062;branch=z9hG4bK2104306013
From: "xxx" <sip:phone_0@example.com>;tag=108111795
To: "xxx" <sip:phone_0@example.com>
Call-ID: 3276145660(a)192.168.1.102
CSeq: 1 SUBSCRIBE
Contact: <sip:phone_0@192.168.1.102:5062>
Accept: application/x-as-feature-event+xml
Max-Forwards: 70
User-Agent: Yealink SIP-T48G 35.72.188.7
Proxy-Require: sip.example.com
Expires: 3630
Event: as-feature-event
Content-Length: 0
```
### Possible Solutions
The code to free the buffer could be duplicated before the return on sanity.c:701.
However, it's not clear to me why the `msg->proxy_require->parsed` structure doesn't get properly free'd when msg is free'd, as most other fields in this struct seem to be destructed correctly.
For now, we disabled the proxy require check with:
```
modparam("sanity", "default_checks", 2535)
```
this mitigates the memory leak.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.2.2 (x86_64/linux)
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 5.3.1
```
Problem still present in current master.
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
Ubuntu 16.04
```
Linux tijscmp01 4.4.0-145-generic #171-Ubuntu SMP Tue Mar 26 12:43:40 UTC 2019 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/1990
### Description
Only the following PVX methods are available on app_ruby:
:sbranch_set_ruri, :sbranch_append, :sbranch_reset, :pv_var_to_xavp, :pv_xavp_to_var, :pv_xavp_print, :xavp_params_explode, :xavp_params_implode, :evalx, :freeze
However pvx.xavp.get() etc are documented:
https://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/modules/#…
#### Reproduction
`KSR.info(KSR::PVX.methods.to_s)`
### Additional Information
kamailio 5.3.0-dev4 (x86_64/linux) 6d43ea
Can be potentially worked around by using `:pv_xavp_to_var` and `KSR::PV.gete()`, however this feels a bit messy
--
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/1987