Re: Fix some ubsan/asan related issues

From: "Tristan Partin" <tristan(at)partin(dot)io>
To: "Junwang Zhao" <zhjwpku(at)gmail(dot)com>
Cc: "Andres Freund" <andres(at)anarazel(dot)de>, "Alexander Lakhin" <exclusion(at)gmail(dot)com>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>, "Heikki Linnakangas" <hlinnaka(at)iki(dot)fi>
Subject: Re: Fix some ubsan/asan related issues
Date: 2024-10-02 04:02:27
Message-ID: D4L0S4PO90TR.22FHV12UROKX1@partin.io
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon Sep 16, 2024 at 9:29 AM EDT, Junwang Zhao wrote:
> I tried your v1-0002, it works at compile phase but failed to run initdb
> with the following leak detected:
>
> =================================================================
> ==64983==ERROR: LeakSanitizer: detected memory leaks
>
> Direct leak of 248 byte(s) in 1 object(s) allocated from:
> #0 0x7fc7729df9cf in __interceptor_malloc
> ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
> #1 0x55bff5480e8b in save_ps_display_args
> ../postgres/src/backend/utils/misc/ps_status.c:190
> #2 0x55bff4a5a298 in main ../postgres/src/backend/main/main.c:90
> #3 0x7fc771924249 in __libc_start_call_main
> ../sysdeps/nptl/libc_start_call_main.h:58
>
> Indirect leak of 19 byte(s) in 1 object(s) allocated from:
> #0 0x7fc77299777b in __interceptor_strdup
> ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
> #1 0x55bff5480f41 in save_ps_display_args
> ../postgres/src/backend/utils/misc/ps_status.c:198
> #2 0x55bff4a5a298 in main ../postgres/src/backend/main/main.c:90
> #3 0x7fc771924249 in __libc_start_call_main
> ../sysdeps/nptl/libc_start_call_main.h:58
>
> I worked around by moving *new_environ* as a global variable, I think this is
> false positive report so maybe this deserves a patch?
>
> I tried to apply your v2 patch set but v2-0004 seems out of date.

Thanks for giving it a try Junwang. I'll rebase this, hopefully tomorrow
and give it another push.

--
Tristan Partin
Neon (https://neon.tech)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tristan Partin 2024-10-02 04:17:15 Re: Converting README documentation to Markdown
Previous Message Tom Lane 2024-10-02 03:57:42 Re: pg_trgm comparison bug on cross-architecture replication due to different char implementation