Skip to content

Commit

Permalink
valgrind: document darwin leaks
Browse files Browse the repository at this point in the history
needs to be supressed.
bsd allocates a fresh struct tm in a helper thread for _r,
which needs to be supressed. it is with glibc.
  • Loading branch information
rurban committed Feb 25, 2018
1 parent d7ff12a commit 8ed1071
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
5 changes: 4 additions & 1 deletion tests/test_ctime_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int test_ctime_s (void)
printf("gmtime() failed\n");
return errs+1;
}
memset(tm, 0, sizeof(struct tm));
/* memset(tm, 0, sizeof(struct tm)); */
#if SIZEOF_TIME_T < 8
/* year 10000, ie 313392063599L would overflow on 32bit */
timer = MAX_TIME_T_STR;
Expand All @@ -90,6 +90,9 @@ int test_ctime_s (void)
debug_printf("year 10000 = %ld\n", (long)timer);
if (timer != -1)
timer++;
#endif
#ifdef BSD_OR_DARWIN_LIKE
/* leak needs to be supressed, darwin valgrind bug */
#endif
}

Expand Down
24 changes: 14 additions & 10 deletions tests/test_gmtime_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,29 @@ int test_gmtime_s (void)
tmptr = gmtime_s(&timer, &tm);
ERRNO(0);
PTRNN(tmptr);
#ifdef BSD_OR_DARWIN_LIKE
/* leak needs to be supressed, darwin valgrind bug */
#endif

timer = -1;
tmptr = gmtime_s(&timer, &tm);
ERRNO(EOVERFLOW);
PTRNULL(tmptr);

{
struct tm* tmp = gmtime(&timer);
memset(tmp, 0, sizeof(struct tm));
tmptr = gmtime(&timer);
/* memset(&tm, 0, sizeof(struct tm)); */
#if SIZEOF_TIME_T < 8
/* year 10000, ie 313392063599L would overflow on 32bit */
timer = MAX_TIME_T_STR;
/* year 10000, ie 313392063599L would overflow on 32bit */
timer = MAX_TIME_T_STR;
#else
tmp->tm_year = 10000;
timer = mktime(tmp);
debug_printf("year 10000 = %ld\n", timer);
timer++;
tmptr->tm_year = 10000;
timer = mktime(tmptr);
debug_printf("year 10000 = %ld\n", timer);
timer++;
#endif
#ifdef BSD_OR_DARWIN_LIKE
/* leak needs to be supressed, darwin valgrind bug */
#endif
}

/* eg. 313392063599L */
tmptr = gmtime_s(&timer, &tm);
Expand Down
24 changes: 14 additions & 10 deletions tests/test_localtime_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,29 @@ int test_localtime_s (void)
tmptr = localtime_s(&timer, &tm);
ERRNO(0);
PTRNN(tmptr);
#ifdef BSD_OR_DARWIN_LIKE
/* leak needs to be supressed, darwin valgrind bug */
#endif

timer = -1;
tmptr = localtime_s(&timer, &tm);
ERRNO(EOVERFLOW);
PTRNULL(tmptr);

{
struct tm *tmp = localtime(&timer);
memset(tmp, 0, sizeof(struct tm));
tmptr = localtime(&timer); /* leaks */
/* memset(&tm, 0, sizeof(struct tm)); */
#if SIZEOF_TIME_T < 8
/* year 10000, ie 313392063599L would overflow on 32bit */
timer = MAX_TIME_T_STR;
/* year 10000, ie 313392063599L would overflow on 32bit */
timer = MAX_TIME_T_STR;
#else
tmp->tm_year = 10000;
timer = mktime(tmp);
debug_printf("year 10000 = %ld\n", timer);
timer++;
tmptr->tm_year = 10000;
timer = mktime(tmptr);
debug_printf("year 10000 = %ld\n", timer);
timer++;
#endif
#ifdef BSD_OR_DARWIN_LIKE
/* leak needs to be supressed, darwin valgrind bug */
#endif
}

/* eg. 313392063599L */
tmptr = localtime_s(&timer, &tm);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wcsfc_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int test_wcsfc_s(void)
WCHECK_SLACK(&str[2], LEN-2);
}

SETLOCALE("lt_LT");
SETLOCALE("lt_LT"); /* leaks 91k on darwin */
SETLANG("lt");
CHKLOCALE("lt")
{
Expand Down

0 comments on commit 8ed1071

Please sign in to comment.