[OpenSIPS-Devel] [opensips] set local variable memory to 0 to prevent core dump (#507)
Jarrod Baumann
notifications at github.com
Tue May 12 20:21:21 CEST 2015
I didn't read the docs to find out cachedb_cassandra wasn't supported with db_cachedb so when I enabled it opensips was seg faulting. This would probably need to be added to the declaration for other engines.
The cachedb_engine variable `cde` in `mod_init` (cachedb_cassandra.c:100) doesn't explicitly set the translation functions of the stack variable to NULL so the check in `db_cachedb_query` (db_cachedb/dbase.c:132) is passed and the db_query_trans tries to execute which faults:
## Before
```
Breakpoint 1, db_cachedb_query (_h=0x7ffff74221a8, _k=0x7fffffffe140, _op=0x0,
_v=0x7fffffffe1a0, _c=0x7fffffffe150, _n=1, _nc=1, _o=0x0,
_r=0x7fffffffe160) at dbase.c:129
warning: Source file is more recent than executable.
129 {
(gdb) n
130 struct db_cachedb_con* ptr = (struct db_cachedb_con *)_h->tail;
(gdb) n
132 if (ptr->cdbf.db_query_trans == NULL) {
(gdb) n
137 return ptr->cdbf.db_query_trans(ptr->cdbc,_h->table,_k,_op,_v,_c,_n,_nc,_o,_r);
(gdb) print *ptr->cdbf.db_query_trans
$1 = {int (cachedb_con *, const str *, const db_key_t *, const db_op_t *,
const db_val_t *, const db_key_t *, const int, const int, const db_key_t,
db_res_t **)} 0x7ffff7420aa8
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7420aa8 in ?? ()
```
## After
```
Breakpoint 1, db_cachedb_query (_h=0x7ffff74221a8, _k=0x7fffffffe140, _op=0x0,
_v=0x7fffffffe1a0, _c=0x7fffffffe150, _n=1, _nc=1, _o=0x0,
_r=0x7fffffffe160) at dbase.c:129
warning: Source file is more recent than executable.
129 {
(gdb) n
130 struct db_cachedb_con* ptr = (struct db_cachedb_con *)_h->tail;
(gdb) n
132 if (ptr->cdbf.db_query_trans == NULL) {
(gdb) n
133 LM_ERR("The selected NoSQL driver cannot convert select queries\n");
(gdb) n
134 return -1;
```
You can view, comment on, or merge this pull request online at:
https://github.com/OpenSIPS/opensips/pull/507
-- Commit Summary --
* set local variable memory to 0 to prevent core dump
-- File Changes --
M modules/cachedb_cassandra/cachedb_cassandra.c (2)
-- Patch Links --
https://github.com/OpenSIPS/opensips/pull/507.patch
https://github.com/OpenSIPS/opensips/pull/507.diff
---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/507
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20150512/9026bb48/attachment.htm>
More information about the Devel
mailing list