Skip to content

LeakSanitizer reporting leak issue from Configure [ithread & clang] #18107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
atoomic opened this issue Sep 1, 2020 · 3 comments
Closed

LeakSanitizer reporting leak issue from Configure [ithread & clang] #18107

atoomic opened this issue Sep 1, 2020 · 3 comments
Labels
Closable? We might be able to close this ticket, but we need to check with the reporter hasPatch metaconfig

Comments

@atoomic
Copy link
Member

atoomic commented Sep 1, 2020

I confirmed that this is an issue with at least the following tags:

  • v5.18.1
  • v5.26.0
  • v5.28.1
  • v5.30.0
  • v5.32.0
  • v5.33.1

You can see the leak when running the following command:

> git clean -dxf; ./Configure -Dusedevel -des -Dcc="ccache clang" -Accflags="-Werror=declaration-after-statement -g -fno-omit-frame-pointer -fsanitize=address  -fno-common -fsanitize-blacklist=`pwd`/asan_ignore" -Aldflags="-fsanitize=address" -Duseithreads

Note: I used Fedora 32 x86_64 to reproduce the issue

Extract from the Configure output

...
lgamma_r() found.
Checking to see if your libm supports _LIB_VERSION...
No, it does not (probably harmless)
link() found.
llrint() found.
llrintl() found.
llround() found.
llroundl() found.
localeconv_l() NOT found.
localtime_r() found.

=================================================================
==328778==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x4bd27f  (/home/atoomic/workspace/perl/UU/try+0x4bd27f)
    #1 0x4f25a9  (/home/atoomic/workspace/perl/UU/try+0x4f25a9)
    #2 0x7fbbea8c6041  (/lib64/libc.so.6+0x27041)

SUMMARY: AddressSanitizer: 16 byte(s) leaked in 1 allocation(s).
lockf() found.
log1p() found.
log2() found.
logb() found.
...

also view: #18012 and #18054

@richardleach
Copy link
Contributor

Looks like the block at https://github.com/Perl/perl5/blob/blead/Configure#L16053. Adding explicit free()s seems to work:

int main()
{
    int result = 0;
    time_t t = time(0L);
    char w_tz[]="TZ" "=GMT+5",
	 e_tz[]="TZ" "=GMT-5",
	*tz_e = (char*)malloc(16),
	*tz_w = (char*)malloc(16);
    struct tm tm_e, tm_w;
    memset(&tm_e,'\0',sizeof(struct tm));
    memset(&tm_w,'\0',sizeof(struct tm));
    strcpy(tz_e,e_tz);
    strcpy(tz_w,w_tz);

    putenv(tz_e);
    localtime_r(&t, &tm_e);

    putenv(tz_w);
    localtime_r(&t, &tm_w);

    if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
	result = 1;

    free(tz_e);free(tz_w);
    return result;
}

richardleach added a commit to richardleach/metaconfig that referenced this issue Sep 2, 2020
To keep LeakSanitizer happy. See Perl/perl5#18107 for background.
@richardleach richardleach added hasPatch metaconfig Severity Low Closable? We might be able to close this ticket, but we need to check with the reporter and removed Needs Triage labels Sep 2, 2020
@richardleach
Copy link
Contributor

Fixed with bb05203?

@atoomic
Copy link
Member Author

atoomic commented Sep 2, 2020

I can confirm that the issue described here is fixed by commit bb05203
thanks @richardleach and @Tux

@atoomic atoomic closed this as completed Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closable? We might be able to close this ticket, but we need to check with the reporter hasPatch metaconfig
Projects
None yet
Development

No branches or pull requests

2 participants