public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/30921] New: timer_create leaks memory after fork
@ 2023-09-29 16:51 arnaud.lb at gmail dot com
  2023-10-02 11:24 ` [Bug libc/30921] " adhemerval.zanella at linaro dot org
  2023-10-02 13:36 ` sam at gentoo dot org
  0 siblings, 2 replies; 3+ messages in thread
From: arnaud.lb at gmail dot com @ 2023-09-29 16:51 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30921

            Bug ID: 30921
           Summary: timer_create leaks memory after fork
           Product: glibc
           Version: 2.34
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: arnaud.lb at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Created attachment 15143
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15143&action=edit
a.c

POSIX specifies that timers created by timer_create() shall not be inherited by
a child process across a fork(). However, resources allocated by timer_create()
leak in the child after a fork(), so forking after timer_create() may leak
memory.

Valgrind trace with the attached `a.c`:


```
; gcc -g -o /tmp/a /tmp/a.c
; valgrind --tool=memcheck --leak-check=full /tmp/a
...
 ==3771539== 88 bytes in 1 blocks are still reachable in loss record 1 of 1     
 ==3771539==    at 0x4848899: malloc (in
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)                        
 ==3771539==    by 0x49206A2: timer_create@@GLIBC_2.34 (timer_create.c:78)      
 ==3771539==    by 0x109286: main (a.c:17)                                      
...
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/30921] timer_create leaks memory after fork
  2023-09-29 16:51 [Bug libc/30921] New: timer_create leaks memory after fork arnaud.lb at gmail dot com
@ 2023-10-02 11:24 ` adhemerval.zanella at linaro dot org
  2023-10-02 13:36 ` sam at gentoo dot org
  1 sibling, 0 replies; 3+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2023-10-02 11:24 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30921

Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adhemerval.zanella at linaro dot o
                   |                            |rg

--- Comment #1 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
I think this is similar to BZ29705, where the timer_crate/SIGEV_THREAD creates
a helper detached thread on the first usage that acts as an activator for the
callbacks.  This is not really a leak, the helper thread will be used on any
subsequent timer_crate/SIGEV_THREAD.

I have sent a possible fix for this and other timer_create issues [1], it
essentially changes how timer_crate/SIGEV_THREAD so each timer_create will
spawn one thread (instead of a helper thread for all timers).

[1]
https://patchwork.sourceware.org/project/glibc/patch/20230921130617.468601-2-adhemerval.zanella@linaro.org/

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/30921] timer_create leaks memory after fork
  2023-09-29 16:51 [Bug libc/30921] New: timer_create leaks memory after fork arnaud.lb at gmail dot com
  2023-10-02 11:24 ` [Bug libc/30921] " adhemerval.zanella at linaro dot org
@ 2023-10-02 13:36 ` sam at gentoo dot org
  1 sibling, 0 replies; 3+ messages in thread
From: sam at gentoo dot org @ 2023-10-02 13:36 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30921

Sam James <sam at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sam at gentoo dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-02 13:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-29 16:51 [Bug libc/30921] New: timer_create leaks memory after fork arnaud.lb at gmail dot com
2023-10-02 11:24 ` [Bug libc/30921] " adhemerval.zanella at linaro dot org
2023-10-02 13:36 ` sam at gentoo dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).