Re: Does opensmppbox and smsbox have serious memory issues?

Andreas Fink <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>

> ==31087== 4,986,528 (77,472 direct, 4,909,056 indirect) bytes in 4,842
> blocks are definitely lost in loss record 813 of 813
> ==31087==    at 0x4027434: malloc (vg_replace_malloc.c:291)
> ==31087==    by 0x80970B3: gw_native_malloc (gwmem-native.c:87)
> ==31087==    by 0x80A37A1: octstr_create_from_data_real (octstr.c:263)
> ==31087==    by 0x80A3916: octstr_create_real (octstr.c:245)
> ==31087==    by 0x80A908E: octstr_format_valist_real (octstr.c:2480)
> ==31087==    by 0x80A9366: octstr_format (octstr.c:2469)
> ==31087==    by 0x80534F5: boxc_route_msg_to_smsc (opensmppbox.c:1791)
> ==31087==    by 0x8057AAE: smpp_to_bearerbox (opensmppbox.c:1638)
> ==31087==    by 0x80983AE: new_thread (gwthread-pthread.c:385)
> ==31087==    by 0x46F9C38: start_thread (pthread_create.c:304)
> ==31087==    by 0x482F78D: clone (clone.S:130)

this seems to be a leak in opensmppbox in this code segment (handle_pdu) in opensmppbox.c around line 1634


	case submit_sm:
		msg = pdu_to_msg(box, pdu, &reason);
		msg2 = msg;
		if (msg == NULL) {
			resp = smpp_pdu_create(generic_nack, pdu->u.submit_sm.sequence_number);
			resp->u.generic_nack.command_status = SMPP_ESME_RUNKNOWNERR;
		}
		else {
			Octstr *smsc_id = boxc_route_msg_to_smsc(box, msg);  <-smsc_id is allocated but never freeed.
			check_multipart(box, msg, &msg_to_send, &msg2, &parts_list);
			msg->sms.smsc_id = smsc_id ? octstr_duplicate(smsc_id) : NULL; /* its duplicated here... */
			msg->sms.boxc_id = octstr_duplicate(box->boxc_id);
			msg_dump(msg, 0);
			resp = smpp_pdu_create(submit_sm_resp, pdu->u.submit_sm.sequence_number);
			msgid = generate_smppid(msg);
			msg->sms.dlr_url = octstr_duplicate(msgid);
			resp->u.submit_sm_resp.message_id = msgid;
			if (msg_to_send) {
				if (DLR_IS_ENABLED(msg2->sms.dlr_mask)) {
					hold_service = msg2->sms.service;
					msg2->sms.service = octstr_format("%ld", msg2->sms.time);
					msgid = generate_smppid(msg2);
					if (parts_list) {
						msg2->sms.dlr_url = concat_msgids(msgid, parts_list);
					}
					dlr_add(box->boxc_id, msgid, msg2);
					octstr_destroy(msgid);
					octstr_destroy(msg2->sms.service);
					msg2->sms.service = hold_service;
				}
				uuid_unparse(msg2->sms.id, id);
				msgid = octstr_create(id);
				dict_put(box->msg_acks, msgid, resp);
				octstr_destroy(msgid);
				resp = NULL;
				send_msg(box->bearerbox_connection, box, msg2);
				if (parts_list) {
					/* destroy values */
					gwlist_destroy(parts_list, msg_destroy_item);
				}
			}
			octstr_destroy(smsc_id); /* fix for this leak */
		}
		break;


This is a leak which would leak a few bytes per SMS.
signature.asc (application/pgp-signature, 841 B)
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQIcBAEBAgAGBQJTXjJ7AAoJEOtfx+3l1p1nUIoQAI1fF0AnzQhNOI6Vi7nqWVK6
NBNHe0ilr4eBjPZjI3vLCcvGv6cyTLdYYfvIZub0RTe9YgRe6zQzgp7dlB5TsBVv
yg2nbvdqSnk8orGLwk+nzIIGWkZP87N6NLj1NVGfhHhTbFrjFBlmB+9OKQ6EfbGM
W3iecuRyQZHvfaAEEkNINWYCbGXdse6lY3XZuclAn8Iz4s1x/hzZlQgkiygviDAJ
n18WbMklIM2hzj5WfdIK4ejoRH1/FeJaB+EUu6WxAHV70+kHRzcUFF1Ml+DLdT/3
wXql7klsp5GTuu4nDilDpZO3AptOFxVC1V0dvBWVS9RRPceCJ+V8GQLvaO8hpxsp
+1QABOeJHVvIyZ4rfPwL8+NZSB4+vDyOsfkxqD6oCbOOlU9mq9Z0ics0GngHRlcW
4lRVMxUATnT20doOix4vHHwoXfcLu4c2Q/2E+ghXfe/gBcFlJTGas4YnnjjyPemq
aew8RRr5pbnPGTC+JwhuwHUIxA9QEqaYCZPriZgQhFjwW/fSmFBdokm1rexukUxj
Lae/HYwec9Y5sR0W/WPGQNI91selb3vsXGE9Rp//DQeXfx3jstEGFEFPXJuqSyNT
RgmZ0PMMAqCCAQFC+8ik1rHK92nBvW8I0ucd/bfc4ZYrfFRZwAtz7k+mltAIVIfq
AfylktBe5R769VUDoF0O
=LKFS
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.