From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway34.websitewelcome.com (gateway34.websitewelcome.com [192.185.149.77]) by sourceware.org (Postfix) with ESMTPS id E31B73858D1E for ; Mon, 9 Jan 2023 15:10:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E31B73858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linumiz.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linumiz.com Received: from atl1wswcm06.websitewelcome.com (unknown [50.6.129.167]) by atl3wswob05.websitewelcome.com (Postfix) with ESMTP id 9978621A81 for ; Mon, 9 Jan 2023 15:10:06 +0000 (UTC) Received: from md-in-79.webhostbox.net ([43.225.55.182]) by cmsmtp with ESMTP id EtmmpBcLJCQuqEtmnp8TVn; Mon, 09 Jan 2023 15:10:06 +0000 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linumiz.com ; s=default; h=Content-Transfer-Encoding:Content-Type:Subject:From:Cc:To: MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3xkTdshrXryaTMDClzvcdRI8Vh6FLQHwS+AAfgCZJYQ=; b=ObBdFSPnes7gHgRq32/O63aZIR yGEgJD7OL43g9+nKyxojWNVrv5QnsZzKxQ9l1COAccUIq5agpG9XXjDuBrsV7IN9CJ9d+Wa6W83Rs vXHwkll/IVTeldfJgQ8jwe0lsShT65Gk+8M/3J+PjveO3sbJEKmRJRFdmUwLUnrvhXIDAZd1+a5lr NhqY5O5A+Q9oRNjFWIYHLzYbca9mbC0Q5g6RTuahnL7gWHF9Zr9rC5YpgYSvM5JSTH88Pg3ml4qQJ Alxzzaehu+aSjpxPdiexfGxMtgb5xDSDcFd38d0WmeU8bRPk9iBnJVS3l0AOoDb6/TEiiEN6nrULF cTptyPQA==; Received: from [117.213.141.130] (port=39290 helo=[192.168.1.6]) by md-in-79.webhostbox.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pEtml-003jRy-EK; Mon, 09 Jan 2023 15:10:03 +0000 Message-ID: Date: Mon, 9 Jan 2023 20:43:13 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US To: libc-help@sourceware.org Cc: Parthiban From: Parthiban Subject: glibc mq_notify memory leak report Organization: Linumiz Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - md-in-79.webhostbox.net X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - linumiz.com X-BWhitelist: no X-Source-IP: 117.213.141.130 X-Source-L: No X-Exim-ID: 1pEtml-003jRy-EK X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.1.6]) [117.213.141.130]:39290 X-Source-Auth: parthiban@linumiz.com X-Email-Count: 1 X-Source-Cap: bGludW1jbWM7aG9zdGdhdG9yO21kLWluLTc5LndlYmhvc3Rib3gubmV0 X-Local-Domain: yes X-CMAE-Envelope: MS4xfHdpzZUTQy0opXrTdfePnTnoKl7u2p1iop4z1qzIsuyGt55A/L6bjCGXrhie7BsGzmg5ApjzkAz4oVa1Ni8/xSYJ1o++l+ArARMPjPvtwun7/JpGHvV5 ywfhZPqH7IMWjSrf3O6LRlAkFcLz4gGc6woMTUvvM1fZPBLaP7teHrV4ujvKhPGg/4KvxtfCRAwxu0i2XzQ1+jAJnnGOe7minHA= X-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Dear All, I have the following code snippet and `mq_close`, `mq_unlink` is called in exit path. But with valgrind, I have the summary about possibly lost. How to gracefully remove the notification during exit path? >From man mq_close, If the calling process has attached a notification request (see (mq_notify(3)) to this message queue via mqdes, then this request is removed Valgrind summary: ``` ==381555== HEAP SUMMARY: ==381555== in use at exit: 5,716 bytes in 13 blocks ==381555== total heap usage: 39,786 allocs, 39,773 frees, 267,728,707 bytes allocated ==381555== ==381555== Thread 1: ==381555== 304 bytes in 1 blocks are possibly lost in loss record 3 of 5 ==381555== at 0x4846A73: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==381555== by 0x4011282: calloc (rtld-malloc.h:44) ==381555== by 0x4011282: allocate_dtv (dl-tls.c:375) ==381555== by 0x4011C91: _dl_allocate_tls (dl-tls.c:634) ==381555== by 0x4F244DF: allocate_stack (allocatestack.c:423) ==381555== by 0x4F244DF: pthread_create@@GLIBC_2.34 (pthread_create.c:650) ==381555== by 0x4F2E70E: init_mq_netlink (mq_notify.c:183) ==381555== by 0x4F28886: __pthread_once_slow (pthread_once.c:116) ==381555== by 0x4F2E802: __mq_notify (mq_notify.c:219) ==381555== by 0x4F2E802: mq_notify@@GLIBC_2.34 (mq_notify.c:203) ==381555== by 0x10C3D1: mq_notify_init (upstream.c:201) ==381555== by 0x10E306: mq_handler_init (upstream.c:1019) ==381555== by 0x10EDB6: upstream_init_async (upstream.c:1244) ==381555== by 0x10BFD6: main (main.c:83) ==381555== ==381555== LEAK SUMMARY: ==381555== definitely lost: 0 bytes in 0 blocks ==381555== indirectly lost: 0 bytes in 0 blocks ==381555== possibly lost: 304 bytes in 1 blocks ==381555== still reachable: 5,412 bytes in 12 blocks ==381555== suppressed: 0 bytes in 0 blocks ``` ``` static int mq_notify_init(void) { int ret; struct sigevent sev; sev.sigev_notify = SIGEV_THREAD; sev.sigev_notify_function = mq_handler; sev.sigev_notify_attributes = NULL; sev.sigev_value.sival_ptr = &mq; ret = mq_notify(mq, &sev); if (ret != 0) error("MQ notify register failed: %s", strerror(errno)); return ret; } ``` -- Thanks, Parthiban N https://www.linumiz.com Berlin, Germany