Bug 509139

Summary: Update BadSize error messages
Product: [Developer tools] valgrind Reporter: Paul Floyd <pjfloyd>
Component: memcheckAssignee: Paul Floyd <pjfloyd>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 3.25 GIT   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Initial patch only tested on FreeBSD
Updated for Linux

Description Paul Floyd 2025-09-05 08:07:40 UTC
The message is currently something like

memalign() invalid size value: 0

For consistency I think that should be something like

Invalid size value: 0 (memalign() size of 0 is implementation defined)

At present 4 functions are affected
posix_memalign - implementation defined by POSIX
memalign - non-standard that can and does do just about anything
aligned_alloc - implementation defined by ISO C which passes the buck and says it is implementation defined
free_sized_aligned - can't remember why I did this (but I didn't do free_sized)

I need to revisit my research into what all these functions do on new glibc, old glibc, FreeBSD, Solaris, macOS, musl, ptmalloc and maybe a couple more.
Comment 1 Paul Floyd 2025-09-07 09:15:31 UTC
I've done a load of tests for size of zero add alignment of zero

https://github.com/paulfloyd/aligned_errors

and pushed a few fixes to the code.

I don't think that I checked whether posix_memalign allocates or not with a size of zero.
Comment 2 Paul Floyd 2025-09-07 19:25:47 UTC
Created attachment 184792 [details]
Initial patch only tested on FreeBSD

Need tol check on Linux and illumos
Comment 3 Paul Floyd 2025-09-07 19:47:54 UTC
Created attachment 184793 [details]
Updated for Linux

next stop illumos
Comment 4 Paul Floyd 2025-09-07 20:04:28 UTC
commit 66f0174466cd0d97d1b123ac8152797fb34aeb8c (HEAD -> master, origin/master, origin/HEAD)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Sun Sep 7 22:01:34 2025 +0200

    Bug 509139 - Update BadSize error messages