Re: Help needed for the resolution of memory leak

From: Sasmit Utkarsh <utkarshsasmit(at)gmail(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Help needed for the resolution of memory leak
Date: 2024-01-17 19:14:40
Message-ID: CAM-5MT1JLf3pjt8oatedX_WzZu77Y6pYCUmoVnmLyU8dQx3TNA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Merlin et al.

Below are some couple of observations attached as an "overview_of_code" and
other attachments "function_def_other_details" and leak sanitizer report.
Please assist with some clarifications given in overview_of_code with
(***). Let me know if you need any more information

Regards,
Sasmit Utkarsh
+91-7674022625

On Wed, Jan 17, 2024 at 12:52 PM Sasmit Utkarsh <utkarshsasmit(at)gmail(dot)com>
wrote:

> Thanks, I'll take a look.
>
> Regards,
> Sasmit Utkarsh
> +91-7674022625
>
>
> On Wed, Jan 17, 2024 at 4:12 AM Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
>
>> On Tue, Jan 16, 2024 at 9:10 AM Sasmit Utkarsh <utkarshsasmit(at)gmail(dot)com>
>> wrote:
>>
>>> 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
>>>
>>
>> You have many other leaks. See code below, you are making up to thee
>> sequential calls to create a result before calling clear. *All *calls
>> creating and returning returning PGresult have to be cleared before the
>> pointer is reused.
>>
>> merlin
>>
>>
>>
>> LOG_DEBUG("%s() conninfo=%s",__func__,conninfo);
>>
>> if(is_shadow_db)
>> {
>> shadow_db_conn = PQconnectdb(shadow_db_conn_info);
>> if ( PQstatus(shadow_db_conn ) != CONNECTION_OK )
>> {
>> LOG_ERROR("Connection to shadow database failed! %s", PQerrorMessage(conn));
>> PQfinish(shadow_db_conn);
>> exit(1);
>> }
>> *res *= PQexec(shadow_db_conn, "SET bytea_output = 'escape'");
>> LOG_DEBUG("%s() Connection to shadow_shc_data database SUCCESSFUL",__func__);
>> // execute_stored_procedure(shadow_db_conn);
>> }
>>
>> conn = PQconnectdb(conninfo);
>> if ( PQstatus(conn) != CONNECTION_OK ) {
>> LOG_ERROR("Connection to database failed! %s", PQerrorMessage(conn));
>> PQfinish(conn);
>> exit(1);
>> } else {
>> *res =* PQexec(conn, "SET bytea_output = 'escape'");
>> LOG_DEBUG("%s() Connection to shc_data database SUCCESSFUL",__func__);
>> }
>>
>> *res *= PQexec(conn, "START TRANSACTION");
>> if (PQresultStatus(res) != PGRES_COMMAND_OK)
>> {
>> LOG_ERROR("START TRANSACTION failed: %s", PQerrorMessage(conn));
>> SQL_exit_nicely(conn,res);
>> }
>> PQclear(res);
>>
>>

Attachment Content-Type Size
LeaskSanitizer report 3.txt text/plain 636.2 KB
overview_of_code.txt text/plain 4.6 KB
fun_def_and_other_details.txt text/plain 11.8 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Johnathan Tiamoh 2024-01-17 20:27:08 Re: pg_basebackup Restore problem
Previous Message Atul Kumar 2024-01-17 18:46:19 unbale to list schema