From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 06C1A396ECE5; Fri, 27 Nov 2020 08:38:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06C1A396ECE5 From: "vries at gcc dot gnu.org" To: glibc-bugs@sourceware.org Subject: [Bug manual/26959] New: __malloc_hook example does not adhere to documented usage Date: Fri, 27 Nov 2020 08:38:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: manual X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Nov 2020 08:38:09 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26959 Bug ID: 26959 Summary: __malloc_hook example does not adhere to documented usage Product: glibc Version: unspecified Status: NEW Severity: minor Priority: P2 Component: manual Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org CC: mtk.manpages at gmail dot com Target Milestone: --- Consider https://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html . It states: ... An issue to look out for is the time at which the malloc hook functions can= be safely installed. If the hook functions call the malloc-related functions recursively, it is necessary that malloc has already properly initialized itself at the time when __malloc_hook etc. is assigned to. ... Then an example follows, which does call malloc recursively, but does nothi= ng specific before __malloc_hook is assigned to for the first time. [ My guess is that the doc list two solutions for the same problem: the fir= st call to malloc may change __malloc_hook from malloc_hook_ini to malloc_chec= k, say if you run with GLIBC_TUNABLES=3Dglibc.malloc.check=3D3. The first solution is to ensure that malloc is called once before saving and then assigning __malloc_hook, such that the saved __malloc_hook value can be assumed to remain constant, and does not need to be saved again after every recursive call to malloc. The second solution is to make sure the __malloc_hook value is saved again after every recursive call to malloc. ] --=20 You are receiving this mail because: You are on the CC list for the bug.=