Hi,
Earlier today I noticed a significant increase of memory consumption by
smsbox. Over a period of 5½ hour it had gone from around 1.8MB to
209MB. When I examined the log of smsbox, two messages were rejected by
smsbox due to bad character formatting, but a minute later the client
attempted to transfer both messages again and again etc.
Judging from this there must be a memory leak in smsbox which is only
triggered upon errors.
I went through some memory dumps and smsbox_req_handle and eventually
concluded that upon errors the allowed, denied, and receiver lists were
not freed.
I've attached a patch which will free the lists on errors in between the
creation and destruction of the lists.
As far as I could see, the elements within the three lists are actually
the same (that is, everything in allowed and denied are definitely also
in received), and since we have not extracted the elements from the
receiver yet, this patch only free the elements in the receiver list.
Not the allowed and denied lists. Is this assumption correct? One thing
is certain, freeing both receiver and allowed with gwlist_destroy(list,
octstr_destroy_item) ended in a PANIC since the first destruction freed
the elements in the other list.
A brute spamming with invalid messages made an unpatched newly started
kannel go from 1.3MB to 10MB in two seconds. The same thing with a
patched kannel went from 1.3MB to 1.5MB where it stayed (I assume that
the first bunch was first-time single-shot allocations). The memory
sizes are RSS.
Another unrelated thing... I've been bombing the mailing list with
patches and stuff the last few weeks, but what exactly is the preferred
way of getting patches? In the mailing list, or by creating a bug report
with an attached patch?
--
Med venlig hilsen / Best regards
Peter Christensen
Developer
------------------
Cool Systems ApS
Tel: +45 2888 1600
@ : [EMAIL PROTECTED]
www: www.coolsystems.dk
diff -Nru gateway/gw/smsbox.c gateway.leak/gw/smsbox.c
--- gateway/gw/smsbox.c 2005-12-09 03:14:31.000000000 +0100
+++ gateway.leak/gw/smsbox.c 2006-01-20 21:30:57.000000000 +0100
@@ -2119,7 +2119,7 @@
newfrom = octstr_duplicate(global_sender);
} else {
returnerror = octstr_create("Sender missing and no global set, rejected");
- goto fielderror2;
+ goto fielderror3;
}
info(0, "sendsms sender:<%s:%s> (%s) to:<%s> msg:<%s>",
@@ -2365,6 +2365,11 @@
octstr_destroy(newfrom);
msg_destroy(msg);
+fielderror3:
+ gwlist_destroy(allowed, NULL);
+ gwlist_destroy(denied, NULL);
+ gwlist_destroy(receiver, octstr_destroy_item);
+
fielderror2:
alog("send-SMS request failed - %s",
octstr_get_cstr(returnerror));