After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 552505 - gcc attribute alloc_size markup
gcc attribute alloc_size markup
Product: libxml2
Classification: Platform
Component: general
Other All
: Normal enhancement
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Reported: 2008-09-16 14:38 UTC by Marcus Meissner
Modified: 2009-01-18 17:27 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement

libxml2-2.7.1-alloc_size.patch (1.77 KB, patch)
2008-09-16 14:39 UTC, Marcus Meissner
none Details | Review

Description Marcus Meissner 2008-09-16 14:38:12 UTC
Following patch adds gcc attribute alloc_size markup to libxml2 allocator
functions. For at-compile-time known sized allocations the compiler tracks the
size of the pointer and can utilize overflow checking in standard mem* and str* functions.

This feature has appearewd with gcc 4.3
Comment 1 Marcus Meissner 2008-09-16 14:39:02 UTC
Created attachment 118826 [details] [review]

patch to add allocsize markup
Comment 2 Daniel Veillard 2008-09-30 16:15:40 UTC
Hi Marcus,

okay that's interesting but I'm a bit confused:

seems to indicate it's useful only if __builtin_object_size
is being used, and I don't use it in libxml2 code, so I'm
wondering a bit about the actual use of the patch just by
itself. Could you explain a bit ?


Comment 3 Marcus Meissner 2008-10-01 13:46:52 UTC
what happens is that the memcpy() memmove() strcpy() etc. standard libc
functions use __builtin_objectg_size() internally.

So if you allocate a at compile time known sized buffer and use one of the
mem* or str* functions with such a known sized destination buffer, it will 
check its size and abort() if the operation would overflow.

Not sure though if you ever allocate compile-time-known sized buffers with those functions or if they are ever passed into mem* or str* functions.
Comment 4 Daniel Veillard 2009-01-18 17:27:59 UTC
Okay, applied thanks !
I had to also fix the apibuild generator to handle the new
extension, but that looks fine and is now commited to SVN,