Summary: | gdb: -Werror=stringop-overflow build failure with -D_GLIBCXX_ASSERTIONS | ||
---|---|---|---|
Product: | gdb | Reporter: | Sam James <sam> |
Component: | build | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED MOVED | ||
Severity: | normal | CC: | arsen, tromey |
Priority: | P2 | ||
Version: | HEAD | ||
Target Milestone: | --- | ||
See Also: | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111073 | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
Sam James
2023-08-18 10:00:10 UTC
this might be a gcc bug. it resembles various other stringop-overflow bugs. a good hint is that it happens inside stl_vector.h. jonathan already (re)verified that the function in question is correct before the release of 13 (as we ran into this while testing libstdc++), at least IIRC (In reply to Arsen Arsenović from comment #1) > this might be a gcc bug. inlined from ‘value* call_function_by_hand_dummy(value*, type*, gdb::array_view<value*>, void (*)(void*, int), void*)’ at infcall.c:1239:23: Looking at the code I see: /* Add the new argument to the front of the argument list. */ new_args.reserve (args.size ()); new_args.push_back (value_from_pointer (lookup_pointer_type (values_type), struct_addr)); new_args.insert (new_args.end (), args.begin (), args.end ()); To me this looks like an off-by-one in the reserve call. At the same time, that should be irrelevant because insert ought to grow the vector anyway. So I tend to agree that it is a compiler problem. I sent a patch for the reserve thing. The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=28bb48114db4de4ba0a72940af1c30728b6e82f2 commit 28bb48114db4de4ba0a72940af1c30728b6e82f2 Author: Tom Tromey <tromey@adacore.com> Date: Fri Aug 18 07:55:30 2023 -0600 Fix off-by-one in call to vector::reserve While looking at a bug, I noticed what I think is an off-by-one mistake in a call to vector::reserve. This code: new_args.reserve (args.size ()); new_args.push_back (value_from_pointer (lookup_pointer_type (values_type), struct_addr)); new_args.insert (new_args.end (), args.begin (), args.end ()); ... reserves 'size()' entries, but then proceeds to push one extra one. This shouldn't have any really bad effects, as insert will grow the vector. Still, it seems better to use the correct size if we're going to bother calling reserve. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30780 Reviewed-by: John Baldwin <jhb@FreeBSD.org> Thank you both. Filed w/ gcc at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111073. I'm closing this as it is a compiler problem. |