From: | Sasmit Utkarsh <utkarshsasmit(at)gmail(dot)com> |
---|---|
To: | Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Help needed for the resolution of memory leak |
Date: | 2024-01-16 15:09:52 |
Message-ID: | CAM-5MT3O2vfH_94kp-OmisR0EWviYwr_MymEf7i_aqcOLsxDZA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Merlin et al.
I have tried to have the above change added in the missing places. Still, I
see the below leaks reported by the address sanitizer. Please see
the attachments for the leak reported and the function definition updated.
Not sure for PQexecPrepared if we call PQclear(res) for cleaning up as
well. let me know if you need any more information
*===================================================================176473==ERROR:
LeakSanitizer: detected memory leaksDirect leak of 197920 byte(s) in 1237
object(s) allocated from: #0 0xf79bc00b in __interceptor_malloc
(/nix/store/7z4l4r0kpgzvsi6zkjz52cvgb8ra06bd-gcc-12.2.0-lib/lib/libasan.so.8+0xbe00b)
#1 0xf78b63f3 in PQmakeEmptyPGresult
(/nix/store/y03rfw0iycp00dxcf8vrmss4nj700fia-postgresql-14.9-lib/lib/libpq.so.5+0x113f3)Indirect
leak of 2531328 byte(s) in 1236 object(s) allocated from: #0 0xf79bc00b
in __interceptor_malloc
(/nix/store/7z4l4r0kpgzvsi6zkjz52cvgb8ra06bd-gcc-12.2.0-lib/lib/libasan.so.8+0xbe00b)
#1 0xf78b604c in pqResultAlloc
(/nix/store/y03rfw0iycp00dxcf8vrmss4nj700fia-postgresql-14.9-lib/lib/libpq.so.5+0x1104c)Indirect
leak of 632832 byte(s) in 1236 object(s) allocated from: #0 0xf79bc00b
in __interceptor_malloc
(/nix/store/7z4l4r0kpgzvsi6zkjz52cvgb8ra06bd-gcc-12.2.0-lib/lib/libasan.so.8+0xbe00b)
#1 0xf78b57e0 in pqAddTuple
(/nix/store/y03rfw0iycp00dxcf8vrmss4nj700fia-postgresql-14.9-lib/lib/libpq.so.5+0x107e0)SUMMARY:
AddressSanitizer: 3362080 byte(s) leaked in 3709 allocation(s).*
Regards,
Sasmit Utkarsh
+91-7674022625
On Tue, Jan 16, 2024 at 12:21 PM Sasmit Utkarsh <utkarshsasmit(at)gmail(dot)com>
wrote:
> Thanks Merlin,
>
> will try to check in other places as well and get back in case any further
> questions
>
>
> Regards,
> Sasmit Utkarsh
> +91-7674022625
>
>
> On Tue, Jan 16, 2024 at 1:30 AM Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
>
>> On Mon, Jan 15, 2024 at 11:32 AM Sasmit Utkarsh <utkarshsasmit(at)gmail(dot)com>
>> wrote:
>>
>>> Hi Team,
>>>
>>> I am trying to test a code which basically tries to read some data from
>>> postgresql db in a loop through a function SQL_get_tpf_rw() whose
>>> definition and other details are shared in the attached file along with the
>>> memory leak report resulted during testing. Could you let me know if i
>>> missed calling anywhere PQclear()
>>> in SQL_get_tpf_rw() which resulted in the below .
>>>
>>> Last few lines from the report
>>>
>>>
>> yep: for example,
>>
>> if (PQresultStatus(*res*) != PGRES_TUPLES_OK)
>> {
>> LOG_ERROR("SELECT failed: %s", PQerrorMessage(conn));
>> LOG_DEBUG("ROLLBACK TRANSACTION AND CHAIN");
>> *res* = PQexec(conn,"ROLLBACK TRANSACTION AND CHAIN");
>> LOG_ERROR("INVALID_FILE_ADDRESS %08X",fa);
>> rc = ERR_INVALID_FILE_ADDRESS;
>>
>>
>> See highlighted bits. You're reusing the res object before clearing it. there may be other cases, but this jumped off the page.
>>
>>
>> merlin
>>
>>
>>
Attachment | Content-Type | Size |
---|---|---|
fun_def_and_other_details.txt | text/plain | 25.2 KB |
LeaskSanitizer report 2.txt | text/plain | 259.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2024-01-16 16:07:52 | Re: Moving to Postgresql database |
Previous Message | Laurenz Albe | 2024-01-16 14:41:47 | Re: Nested-Internal Functions |