Den4t created an issue (kamailio/kamailio#4391)
Hi !
Kamailio v.5.8.6, used as webrtc registrar/GW, wolfssl v.5.7.4, high call load, OS: Ubuntu 22
Periodically kamailio dumps core with assertion:
```
Program terminated with signal SIGABRT, Aborted.
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140585212159808) at ./nptl/pthread_kill.c:44
44 ./nptl/pthread_kill.c: No such file or directory.
(gdb) backtrace
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140585212159808) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=140585212159808) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=140585212159808, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007fdc8ba5f476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007fdc8ba457f3 in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007fdc8ba4571b in __assert_fail_base (fmt=0x7fdc8bbfa130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7fdc7a6b299f "nw == bytes_read", file=0x7fdc7a6b089a "tls_server.c", line=1056, function=<optimized out>) at ./assert/assert.c:94
#6 0x00007fdc8ba56e96 in __GI___assert_fail (assertion=0x7fdc7a6b299f "nw == bytes_read", file=0x7fdc7a6b089a "tls_server.c", line=1056, function=0x7fdc7a6b5068 "tls_h_read_f") at ./assert/assert.c:103
#7 0x00007fdc7a48cd89 in tls_h_read_f () from /usr/lib64/kamailio/modules/tls_wolfssl.so
#8 0x00005622baa30e8e in ?? ()
#9 0x00005622baa3273b in tcp_read_req ()
#10 0x00005622baa3c7c2 in ?? ()
#11 0x00005622babf61d6 in ?? ()
#12 0x00005622baa42b87 in tcp_receive_loop ()
#13 0x00005622baa24188 in tcp_init_children ()
#14 0x00005622ba7b1b33 in main_loop ()
#15 0x00005622ba7a5888 in main ()
```
I couldn't reproduce this issue in a lab, but I think that possibly the issue depends on TLS traffic burst behavior.
We have some buggy webrtc clients, which floods using MESSAGE requests with high CPS periodically.
I assume that might be this traffic somehow fills the BIO buffers in wolfssl. As result wolfSSL_BIO_write function returns with error.
I have no time to debug deeply, so I made a quick fix here:
https://github.com/Den4t/kamailio/commit/20579f02354356dedb5f5ac1f9bff65314…
I see following logs after the fix has been applied:
```
2025-09-02T09:24:04.393019+03:00 iptel /usr/sbin/kamailio[892554]: BUG: tls_wolfssl [tls_server.c:1058]: tls_h_read_f(): tls_h_read_f assertion check nw == bytes_read (nw=-1, bytes_read=7115,
npos=-1)
2025-09-02T10:44:21.556481+03:00 iptel /usr/sbin/kamailio[892559]: BUG: tls_wolfssl [tls_server.c:1058]: tls_h_read_f(): tls_h_read_f assertion check nw == bytes_read (nw=-1, bytes_read=6201,
npos=-1)
2025-09-02T10:58:31.563456+03:00 iptel /usr/sbin/kamailio[892558]: BUG: tls_wolfssl [tls_server.c:1058]: tls_h_read_f(): tls_h_read_f assertion check nw == bytes_read (nw=-1, bytes_read=7587,
npos=-1)
```
But service is alive.
It is better to lose one session than the whole service.
In any case this is just a crutch for quick problem fix, so it would be nice if tls_wolfssl module's author took a deeper look at the problem.
P.S.
I assume that module's logic should check BIO flags after the call to wolfSSL_BIO_write, f.e. this function can return error with bio flag WOLFSSL_BIO_FLAG_RETRY set.
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4391
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/4391(a)github.com>
#### Pre-Submission Checklist
- [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
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
This PR moves the selected hash up the call stack so it is more accessible in failover, and by the higher order functions.
It is a little hard to see the benefit until I get the next few patchsets submitted, but I will link them below this description.
The biggest benefit for other dispatcher algorithm developers is that the hash selected is now available on failover and can be used to lookup attrs (or any other info) needed for implementing more complex failure scenarios.
These are the examples I am working on that depend on this change (as an example of how it can be used):
1. [rpc commands][1] - an example where a user can test selection algorithms with a dataset, without stepping into gdb
2. [failover selection][2] - an example algorithm that makes use of this change for re-balancing the distribution on failover (in mode 1)
[1]: https://github.com/devopsec/kamailio/tree/dispatcher_rpc_updates
[2]: https://github.com/devopsec/kamailio/tree/dispatcher_alg_updates
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/4500
-- Commit Summary --
* dispatcher: make hash result more accessible
-- File Changes --
M src/modules/dispatcher/dispatch.c (201)
M src/modules/dispatcher/dispatch.h (16)
M src/modules/dispatcher/dispatcher.c (148)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/4500.patchhttps://github.com/kamailio/kamailio/pull/4500.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/4500
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/4500(a)github.com>
#### 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
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] 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 -->
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [x] Related to issue #4315
#### Description
Added a function to check the flow token.
Useful to make sure the client TCP connection is alive.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/4449
-- Commit Summary --
* outbound: added check_flow_token function
* outbound: docbook - fixed 'Attribute "xmlns:xi" must be declared for element type'
* outbound: fixed xml validation errors
* outbound: added check_flow_token documentation
-- File Changes --
M src/modules/outbound/doc/outbound.xml (3)
M src/modules/outbound/doc/outbound_admin.xml (78)
M src/modules/outbound/outbound_mod.c (149)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/4449.patchhttps://github.com/kamailio/kamailio/pull/4449.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/4449
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/4449(a)github.com>
sergey-safarov created an issue (kamailio/kamailio#4315)
### Description
Use case WebRTC client connected to Kaamilio Edge proxy.
For network connectivity reasons, the flow token may no longer be valid. In this case, behavior should be described in the [RFC5626, 5.3.1 Processing Incoming Requests](https://datatracker.ietf.org/doc/html/rfc5626#section-5.3.1)
> If the flow no longer exists, the proxy SHOULD send a 430 (Flow Failed) response to the request.
Also [9.3 Incoming Call and Proxy Crash](https://datatracker.ietf.org/doc/html/rfc5626#section-9.3)
> Bob's authoritative proxy first tries the flow to EP1, but EP1 no longer has a flow to Bob, so it responds with a 430 (Flow Failed) response.
To get it working, it will be fine to use construction like
```
if (!loose_route()) {
switch($rc) {
case -4:
sl_send_reply("403", "Flow Failed");
exit;
case -2:
sl_send_reply("403", "Forbidden");
exit;
default:
xlog("L_ERR", "in request_route\n");
sl_reply_error();
exit;
}
}
```
Where `loose_route` returns a new error code (`-4` for example). This error code is generated when the flow token points to not existing TCP/TLS/WSS connection.
### Expected behavior
Kamailio `loose_route` allows the check of flow token validity before messages related via non-existent TCP/TLS/WSS connections.
#### Actual observed behavior
For now, Kamailio tries to relay messages to non-existent client connections and generate an error message like
```
477 Unfortunately error on sending to next hop occurred (477/TM)
500 Message processing error (2/TM)
```
#### How to reproduce
Required to start Kamailio with a config like
```
listen=udp:127.0.0.1:5060
listen=tcp:127.0.0.1:5060
loadmodule "pv.so"
loadmodule "xlog.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "siputils.so"
loadmodule "rr.so"
loadmodule "stun.so"
loadmodule "outbound.so"
modparam("outbound", "force_outbound_flag", 1)
modparam("outbound", "flow_token_secret", "kamailio")
loadmodule "debugger.so"
modparam("debugger", "cfgtrace", 1)
modparam("debugger", "log_level_name", "exec")
request_route {
loose_route();
switch($rc) {
case -3:
xlog("L_ERR", "loose_route code -3\n");
break;
case -2:
xlog("L_ERR", "loose_route code -2\n");
break;
case -1:
xlog("L_ERR", "loose_route code -1\n");
break;
case 1:
xlog("L_ERR", "loose_route code 1\n");
break;
case 2:
xlog("L_ERR", "loose_route code 2\n");
break;
}
record_route();
if (has_totag()) {
t_relay();
} else {
t_relay_to_udp("127.0.0.1", "5080");
}
}
```
Then need to start SIPp server script using the command
```
sipp -sf uas.xml -p 5080 -d 4000 -bind_local 127.0.0.1
```
And then start SIPp client script using the command
```
sipp -sf uac.xml -m 1 -t t1 127.0.0.1
```
Where `uac.xml` and `uas.xml` are attached
[sipp-scripts.tar.gz](https://github.com/user-attachments/files/21187724/sip…
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4315
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/4315(a)github.com>
sergey-safarov created an issue (kamailio/kamailio#4484)
```
/root/rpmbuild/BUILD/kamailio-6.1.0-dev1/src/modules/ims_qos_npn/rx_aar.c:671:69: warning: ‘rpl_sdp_session’ may be used uninitialized [-Wmaybe-uninitialized]
671 | ipB = rpl_sdp_session->ip_addr;
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/root/rpmbuild/BUILD/kamailio-6.1.0-dev1/src/modules/ims_qos_npn/rx_aar.c:560:47: note: ‘rpl_sdp_session’ was declared here
560 | sdp_session_cell_t *req_sdp_session, *rpl_sdp_session;
| ^~~~~~~~~~~~~~~
/root/rpmbuild/BUILD/kamailio-6.1.0-dev1/src/modules/ims_qos_npn/rx_aar.c:620:35: warning: ‘rpl_sdp_stream’ may be used uninitialized [-Wmaybe-uninitialized]
620 | if(rpl_sdp_stream) {
| ^
/root/rpmbuild/BUILD/kamailio-6.1.0-dev1/src/modules/ims_qos_npn/rx_aar.c:561:45: note: ‘rpl_sdp_stream’ was declared here
561 | sdp_stream_cell_t *req_sdp_stream, *rpl_sdp_stream;
| ^~~~~~~~~~~~~~
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4484
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/4484(a)github.com>
sergey-safarov created an issue (kamailio/kamailio#4457)
### Description
For now, `htable` exporting `table_spec` and `init_tables`. [Link](https://github.com/kamailio/kamailio/blob/18beef305002e6b2a4a6504273a…
When spec contains `dbmode=1`, then data is not loaded from the database, and `htable` cache data is not available after Kamailio restart.
It would be fine to expose `ht_db_load_tables` via `htable` API and other Kamailio modules can get cache after Kamailio restart.
### Expected behavior
htables defined via API with param dbmode=1 loaded after Kamailio restart.
#### Actual observed behavior
htables cache is not loaded after Kamailio restart if the table is created via API.
### Possible Solutions
Probably it can be done using this change
```diff
From 72e1aea56efa16ecd50806baa94a5cc0f62d37d6 Mon Sep 17 00:00:00 2001
From: Nikolay Ivanuschak <ivanuschak.nikolay(a)gmail.com>
Date: Wed, 29 Oct 2025 22:57:49 +0300
Subject: [PATCH] htable: added db API functions
---
src/modules/htable/api.c | 25 +++++++++++++++++++++++++
src/modules/htable/api.h | 9 +++++++++
2 files changed, 34 insertions(+)
diff --git a/src/modules/htable/api.c b/src/modules/htable/api.c
index 94095d3d5d..02b299d8c4 100644
--- a/src/modules/htable/api.c
+++ b/src/modules/htable/api.c
@@ -26,6 +26,7 @@
#include "../../core/dprint.h"
#include "ht_api.h"
+#include "ht_db.h"
#include "api.h"
#include "ht_dmq.h"
@@ -157,6 +158,26 @@ int ht_api_init_tables(void)
return ht_init_tables();
}
+int ht_api_db_open_con(void)
+{
+ return ht_db_open_con();
+}
+
+int ht_api_db_close_con(void)
+{
+ return ht_db_close_con();
+}
+
+int ht_api_db_load_tables(void)
+{
+ return ht_db_load_tables();
+}
+
+int ht_api_db_sync_tables(void)
+{
+ return ht_db_sync_tables();
+}
+
/**
*
*/
@@ -175,5 +196,9 @@ int bind_htable(htable_api_t *api)
api->get_expire = ht_api_get_cell_expire;
api->rm_re = ht_api_rm_cell_re;
api->count_re = ht_api_count_cells_re;
+ api->db_open_con = ht_api_db_open_con;
+ api->db_close_con = ht_api_db_close_con;
+ api->db_load_tables = ht_api_db_load_tables;
+ api->db_sync_tables = ht_api_db_sync_tables;
return 0;
}
diff --git a/src/modules/htable/api.h b/src/modules/htable/api.h
index 2e84f2e0da..1f0a547434 100644
--- a/src/modules/htable/api.h
+++ b/src/modules/htable/api.h
@@ -38,6 +38,11 @@ typedef int (*ht_api_set_cell_expire_f)(
typedef int (*ht_api_get_cell_expire_f)(
str *hname, str *name, unsigned int *val);
+typedef int (*ht_api_db_open_con_f)(void);
+typedef int (*ht_api_db_close_con_f)(void);
+typedef int (*ht_api_db_load_tables_f)(void);
+typedef int (*ht_api_db_sync_tables_f)(void);
+
typedef int (*ht_api_rm_cell_re_f)(str *hname, str *sre, int mode);
typedef int (*ht_api_count_cells_re_f)(str *hname, str *sre, int mode);
@@ -52,6 +57,10 @@ typedef struct htable_api
ht_api_get_cell_expire_f get_expire;
ht_api_rm_cell_re_f rm_re;
ht_api_count_cells_re_f count_re;
+ ht_api_db_open_con_f db_open_con;
+ ht_api_db_close_con_f db_close_con;
+ ht_api_db_load_tables_f db_load_tables;
+ ht_api_db_sync_tables_f db_sync_tables;
} htable_api_t;
typedef int (*bind_htable_f)(htable_api_t *api);
--
2.51.0
```
Here exposed `db_open_con`, `db_close_con`, also because required to make sure database connections are present before reading the database.
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4457
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/4457(a)github.com>
itpanda2024 created an issue (kamailio/kamailio#4467)
<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for bug reports.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* https://lists.kamailio.org/mailman3/postorius/lists/sr-users.lists.kamailio…
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* https://lists.kamailio.org/mailman3/postorius/lists/sr-dev.lists.kamailio.o…
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
Note that an issue report may be closed automatically after about 2 months
if there is no interest from developers or community users on pursuing it, being
considered expired. In such case, it can be reopened by writing a comment that includes
the token `/notexpired`. About two weeks before considered expired, the issue is
marked with the label `stale`, trying to notify the submitter and everyone else
that might be interested in it. To remove the label `stale`, write a comment that
includes the token `/notstale`. Also, any comment postpone the `expire` timeline,
being considered that there is interest in pursuing the issue.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### Description
<!--
We use db_cluster module with configuration below :
loadmodule "db_mysql.so"
modparam("db_mysql", "timeout_interval", 2)
loadmodule "db_cluster.so"
modparam("db_mysql", "timeout_interval", 2)
modparam("db_cluster", "connection","cfig_db1=>mysql://kamailio:kamailiorw@localhost/kamailio")
modparam("db_cluster", "connection","cfig_db2=>mysql://kamailio_user:Kam2025Db@172.20.22.12/kamailio")
modparam("db_cluster", "cluster", "cfig_db=>cfig_db1=9s8r;cfig_db2=9s8r")
modparam("db_cluster", "inactive_interval", 180)
modparam("db_cluster", "max_query_length", 5)
But we stop db1 . Kamailio fail ,not change to connect db2 and kamailio service stoped.
-->
### Troubleshooting
#### Reproduction
<!--
Nov 11 09:43:56 kam-02 kamailio[249517]: 391(249517) INFO: db_cluster [db_cluster_mod.c:192]: dbcl_rpc_list_connections(): read connection [cfig_db2]
Nov 11 09:43:56 kam-02 kamailio[249517]: 391(249517) INFO: db_cluster [db_cluster_mod.c:192]: dbcl_rpc_list_connections(): read connection [cfig_db1]
Nov 11 09:44:12 kam-02 kamailio[249509]: 387(249509) ERROR: db_mysql [km_dbase.c:129]: db_mysql_submit_query_impl(): driver error on query: Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (2) (2002)
Nov 11 09:44:12 kam-02 kamailio[249509]: 387(249509) ERROR: <core> [db_query.c:335]: db_do_delete(): error while submitting query
Nov 11 09:44:12 kam-02 kernel: kamailio[249509]: segfault at 0 ip 00007f02cb456312 sp 00007fff12a9a3f0 error 4 in db_cluster.so[12312,7f02cb446000+2f000] likely on CPU 3 (core 0, socket 6)
Nov 11 09:44:12 kam-02 kernel: Code: 84 89 c7 e8 c0 fd fe ff 48 8b 4d a0 8b 45 c0 48 63 f0 8b 45 c4 48 63 d0 48 89 d0 48 c1 e0 03 48 29 d0 48 01 f0 48 8b 44 c1 18 <4c> 8b 38 48 8b 4d a0 8b 45 c0 48 63 f0 8b 45 c4 48 63 d0 48 89 d0
Nov 11 09:44:12 kam-02 systemd-coredump[249541]: Process 249509 (kamailio) of user 993 terminated abnormally with signal 11/SEGV, processing...
Nov 11 09:44:12 kam-02 systemd[1]: Started systemd-coredump(a)2-249541-0.service - Process Core Dump (PID 249541/UID 0).
Nov 11 09:44:13 kam-02 systemd-coredump[249542]: Process 249509 (kamailio) of user 993 dumped core.#012#012Module libuuid.so.1 from rpm util-linux-2.40.2-10.el10.x86_64#012Module libpcre2-8.so.0 from rpm pcre2-10.44-1.0.1.el10.3.x86_64#012Module libcrypt.so.2 from rpm libxcrypt-4.4.36-10.el10.x86_64#012Module libselinux.so.1 from rpm libselinux-3.8-2.el10_0.x86_64#012Module libbrotlicommon.so.1 from rpm brotli-1.1.0-6.el10.x86_64#012Module libsasl2.so.3 from rpm cyrus-sasl-2.1.28-27.el10.x86_64#012Module libevent-2.1.so.7 from rpm libevent-2.1.12-16.el10.x86_64#012Module libkeyutils.so.1 from rpm keyutils-1.6.3-5.el10.x86_64#012Module libkrb5support.so.0 from rpm krb5-1.21.3-8.0.1.el10_0.x86_64#012Module libcom_err.so.2 from rpm e2fsprogs-1.47.1-3.el10.x86_64#012Module libk5crypto.so.3 from rpm krb5-1.21.3-8.0.1.el10_0.x86_64#012Module libkrb5.so.3 from rpm krb5-1.21.3-8.0.1.el10_0.x86_64#012Module libunistring.so.5 from rpm libunistring-1.1-10.el10.x86_64#012Module libz.so.1 from rpm zlib-ng-2.2.3-1.el10.x86_64#012Module libbrotlidec.so.1 from rpm brotli-1.1.0-6.el10.x86_64#012Module libgssapi_krb5.so.2 from rpm krb5-1.21.3-8.0.1.el10_0.x86_64#012Module libcrypto.so.3 from rpm openssl-3.2.2-16.0.1.el10_0.4.x86_64#012Module libssl.so.3 from rpm openssl-3.2.2-16.0.1.el10_0.4.x86_64#012Module libpsl.so.5 from rpm libpsl-0.21.5-6.el10.x86_64#012Module libssh.so.4 from rpm libssh-0.11.1-4.el10_0.x86_64#012Module libidn2.so.0 from rpm libidn2-2.3.7-3.el10.x86_64#012Module libnghttp2.so.14 from rpm nghttp2-1.64.0-2.el10.x86_64#012Module libcurl.so.4 from rpm curl-8.9.1-5.el10.x86_64#012Module libcap.so.2 from rpm libcap-2.69-7.el10.x86_64#012Module libnss_myhostname.so.2 from rpm systemd-257-9.0.1.el10_0.1.x86_64#012Stack trace of thread 249509:#012#0 0x00007f02cb456312 db_cluster_delete (db_cluster.so + 0x12312)#012#1 0x00007f02cb3b461d tps_db_clean_branches (topos.so + 0x2e61d)#012#2 0x00007f02cb3cae2f tps_storage_clean (topos.so + 0x44e2f)#012#3 0x00000000006dd64f sr_wtimer_exec (/usr/local/sbin/kamailio + 0x2dd64f)#012#4 0x00000000006dc71d fork_sync_timer (/usr/local/sbin/kamailio + 0x2dc71d)#012#5 0x00000000006dd9c3 sr_wtimer_start (/usr/local/sbin/kamailio + 0x2dd9c3)#012#6 0x000000000042eea0 main_loop (/usr/local/sbin/kamailio + 0x2eea0)#012#7 0x000000000043902c main (/usr/local/sbin/kamailio + 0x3902c)#012#8 0x00007f02f04f230e __libc_start_call_main (libc.so.6 + 0x2a30e)#012#9 0x00007f02f04f23c9 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x2a3c9)#012#10 0x000000000041dc65 _start (/usr/local/sbin/kamailio + 0x1dc65)#012ELF object binary architecture: AMD x86-64
-->
#### Debugging Data
<!--
If you got a core dump, use gdb to extract troubleshooting data - full backtrace,
local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile
bt full
info locals
list
If you are familiar with gdb, feel free to attach more of what you consider to
be relevant.
Module libuuid.so.1 from rpm util-linux-2.40.2-10.el10.x86_64
Module libpcre2-8.so.0 from rpm pcre2-10.44-1.0.1.el10.3.x86_64
Module libcrypt.so.2 from rpm libxcrypt-4.4.36-10.el10.x86_64
Module libselinux.so.1 from rpm libselinux-3.8-2.el10_0.x86_64
Module libbrotlicommon.so.1 from rpm brotli-1.1.0-6.el10.x86_64
Module libsasl2.so.3 from rpm cyrus-sasl-2.1.28-27.el10.x86_64
Module libevent-2.1.so.7 from rpm libevent-2.1.12-16.el10.x86_64
Module libkeyutils.so.1 from rpm keyutils-1.6.3-5.el10.x86_64
Module libkrb5support.so.0 from rpm krb5-1.21.3-8.0.1.el10_0.x86_64
Module libcom_err.so.2 from rpm e2fsprogs-1.47.1-3.el10.x86_64
Module libk5crypto.so.3 from rpm krb5-1.21.3-8.0.1.el10_0.x86_64
Module libkrb5.so.3 from rpm krb5-1.21.3-8.0.1.el10_0.x86_64
Module libunistring.so.5 from rpm libunistring-1.1-10.el10.x86_64
Module libz.so.1 from rpm zlib-ng-2.2.3-1.el10.x86_64
Module libbrotlidec.so.1 from rpm brotli-1.1.0-6.el10.x86_64
Module libgssapi_krb5.so.2 from rpm krb5-1.21.3-8.0.1.el10_0.x86_64
Module libcrypto.so.3 from rpm openssl-3.2.2-16.0.1.el10_0.4.x86_64
Module libssl.so.3 from rpm openssl-3.2.2-16.0.1.el10_0.4.x86_64
Module libpsl.so.5 from rpm libpsl-0.21.5-6.el10.x86_64
Module libssh.so.4 from rpm libssh-0.11.1-4.el10_0.x86_64
Module libidn2.so.0 from rpm libidn2-2.3.7-3.el10.x86_64
Module libnghttp2.so.14 from rpm nghttp2-1.64.0-2.el10.x86_64
Module libcurl.so.4 from rpm curl-8.9.1-5.el10.x86_64
Module libcap.so.2 from rpm libcap-2.69-7.el10.x86_64
Module libnss_myhostname.so.2 from rpm systemd-257-9.0.1.el10_0.1.x86_64
Stack trace of thread 250950:
#0 0x00007feac2913312 db_cluster_delete (db_cluster.so + 0x12312)
#1 0x00007feac287161d tps_db_clean_branches (topos.so + 0x2e61d)
#2 0x00007feac2887e2f tps_storage_clean (topos.so + 0x44e2f)
#3 0x00000000006dd64f sr_wtimer_exec (/usr/local/sbin/kamailio + 0x2dd64f)
#4 0x00000000006dc71d fork_sync_timer (/usr/local/sbin/kamailio + 0x2dc71d)
#5 0x00000000006dd9c3 sr_wtimer_start (/usr/local/sbin/kamailio + 0x2dd9c3)
#6 0x000000000042eea0 main_loop (/usr/local/sbin/kamailio + 0x2eea0)
#7 0x000000000043902c main (/usr/local/sbin/kamailio + 0x3902c)
#8 0x00007feae79ac30e __libc_start_call_main (libc.so.6 + 0x2a30e)
#9 0x00007feae79ac3c9 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x2a3c9)
#10 0x000000000041dc65 _start (/usr/local/sbin/kamailio + 0x1dc65)
ELF object binary architecture: AMD x86-64
-->
```
(paste your debugging data here)
```
#### Log Messages
<!--
Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your log messages here)
```
#### SIP Traffic
<!--
If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your sip traffic here)
```
### Possible Solutions
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix.
-->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
(paste your output here)
```
* **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 `lsb_release -a` and `uname -a`)
-->
```
(paste your output here)
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4467
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/4467(a)github.com>
wedhornsipgate created an issue (kamailio/kamailio#4426)
**Description:**
We're missing a KEMI function in the htable module that provides the same functionality as the PV function `$shtcn(table=>pattern)` to count the number of keys in an htable that match a given pattern (prefix/suffix/regex). The goal is to let KEMI scripts perform pattern counts without constructing dynamic PV expressions, which currently causes unbounded pv_cache growth in PKG memory.
**Use case / motivation:**
We implemented rolling-window rate limiting by writing short-lived, per-call entries into an htable and then counting keys that match a number-derived pattern. Using $shtcn() works well for the logic, but in KEMI (JS/TypeScript) we must call it via pv.gete("$shtcn(...)"). Because the PV string varies per INVITE (different pattern/key each time), these dynamic PV expressions accumulate in the PV cache, growing PKG/private memory over time.
We’d like a native KEMI function to perform the same count/match so we can avoid the PV layer entirely.
**Environment**
Kamailio: 5.8.6 on Debian 12
Scripting: KEMI (JavaScript/TypeScript)
Symptom: steady PKG/private memory increase over ~24h under load when using pv.gete("$shtcn(...)"). Disabling the $shtcn() call stops the growth.
Related log line: the one discussed in [#3440](https://github.com/kamailio/kamailio/issues/3440) (“pv cache … pkg memory may get filled with pv declarations”).
Current line in our script:
```if (ksr.pv.gete(`$shtcn(${htable_count}=>%~${number})`) > threshold) { ... }```
**Current workaround**
Restarting the Kamailio every day or disabling rate limit on instances with KEMI.
**Idea for API**
Minimal, PV-parity:
```
// KEMI export
int shtcn_match(str table, str pattern, int mode /* 0=exact, 1=prefix, 2=suffix, 3=regex */);
```
JS example:
`const n = KSR.htable.shtcn_match("from_number_count", number, 3); // regex`
More explicit helpers (avoids integer modes):
```
KSR.htable.shtcn_exact(table, key) -> int
KSR.htable.shtcn_prefix(table, prefix) -> int
KSR.htable.shtcn_suffix(table, suffix) -> int
KSR.htable.shtcn_regex(table, pattern) -> int
```
**Behavioral notes / expectations**
Should mirror $shtcn() semantics where reasonable (esp. regex behavior), but returning an integer directly to KEMI.
Must not allocate PV expressions or interact with pv_cache.
**Why this belongs in htable KEMI**
$shtcn() is already offered at the PV level; parity in KEMI keeps feature consistency across scripting engines.
It enables memory-safe implementations of rolling-window rate limits and similar patterns (without touching PV).
**Alternatives considered**
Replace pattern counting with per-bucket counters (sht_inc), which leads to other problems like increment/decrement handling and locking.
Use ratelimit/pike modules—useful for IP/method limits, but our use case is PAI/From/To based and currently hinges on pattern counts.
**Acceptance criteria**
A KEMI function exists to count matching keys in an htable without PV parsing.
Verified that repeated calls with dynamic patterns do not grow PV cache / PKG memory.
Basic tests for exact/prefix/suffix/regex modes (and skip_expired if implemented).
Thank you!
This would let KEMI users keep $shtcn()-style logic with the same performance characteristics, but without the PV-cache side effects.
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4426
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/4426(a)github.com>
- add sht_is_null route function
- add sht_inc route function
- add sht_dec route function
#### Pre-Submission Checklist
- [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
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
Implementing the identical functions from KEMI in the route functions.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/4499
-- Commit Summary --
* htable: feature parity with kemi funcs
-- File Changes --
M src/modules/htable/doc/htable.xml (2)
M src/modules/htable/doc/htable_admin.xml (105)
M src/modules/htable/htable.c (95)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/4499.patchhttps://github.com/kamailio/kamailio/pull/4499.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/4499
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/4499(a)github.com>