https://bugs.kde.org/show_bug.cgi?id=506967

--- Comment #3 from Mark Wielaard <[email protected]> ---
(In reply to mcermak from comment #2)
> Created attachment 183301 [details]
> WIP patch
> 
> I've attempted to model mallinfo2() after mallinfo().  My attached WIP patch
> does compile fine.

Patch looks good, just one issue:

+/* This struct definition MUST match the system one. */
+/* SVID2/XPG mallinfo structure */
+#include <stddef.h> /* for size_t */
+struct vg_mallinfo2 {
+   size_t arena;    /* total space allocated from system */
+   size_t ordblks;  /* number of non-inuse chunks */
+   size_t smblks;   /* unused -- always zero */
+   size_t hblks;    /* number of mmapped regions */
+   size_t hblkhd;   /* total space in mmapped regions */
+   size_t usmblks;  /* unused -- always zero */
+   size_t fsmblks;  /* unused -- always zero */
+   size_t uordblks; /* total allocated space */
+   size_t fordblks; /* total non-inuse space */
+   size_t keepcost; /* top-most, releasable (via malloc_trim) space */
+};

Please don't #include <stddef.h> and use SizeT instead of size_t.
In general we try to not use libc or kernel headers but define our own types.

>  But running the following test:
> 
> > $ ./vg-in-place 
> > ./auxprogs/auxchecks/ltp-full-20250530/testcases/kernel/syscalls/mallinfo2/mallinfo2_01
> >   |& fgrep overflow
> > mallinfo2_01.c:35: TFAIL: hblkhd member of struct mallinfo2 overflow?
> > $
> 
> Makes me think that the new override function mallinfo2() still somehow
> isn't properly wired in.
> 
> Any thoughts?

You comment explains I think:

+   // We don't have fastbins so smblks & fsmblks are always 0. Also we don't
+   // have a separate mmap allocator so set hblks & hblkhd to 0.

So the testcase tests something we don't support. It seems to test an glibc
implementation detail.

Note that something similar is true for
testcases/kernel/syscalls/mallinfo/mallinfo02
mallinfo02.c:41: TFAIL: malloc uses sbrk when size >= 128k
Which also testes info.hblks > 0.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to