public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/109256] New: Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12)
@ 2023-03-23  4:06 james.hilliard1 at gmail dot com
  2023-03-23  4:11 ` [Bug target/109256] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: james.hilliard1 at gmail dot com @ 2023-03-23  4:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109256

            Bug ID: 109256
           Summary: Error: failed to link 'linked_maps2.bpf.o': Cannot
                    allocate memory (12)
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: james.hilliard1 at gmail dot com
  Target Milestone: ---

I'm seeing this gen object error which does not occur in llvm for a bpf
test(which uses both linked_maps1.c and linked_maps2.c) in bpf-next.

It seems this is triggering a double free in libbpf, not entirely clear if this
is a gcc issue or libbpf issue.

GCC gen object failure:
==2125110== Command:
/home/buildroot/bpf-next/tools/testing/selftests/bpf/tools/sbin/bpftool --debug
gen object
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps.linked1.o
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps1.bpf.o
/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps2.bpf.o
==2125110== 
libbpf: linker: adding object file
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps1.bpf.o'...
libbpf: linker: adding object file
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps2.bpf.o'...
Error: failed to link
'/home/buildroot/bpf-next/tools/testing/selftests/bpf/bpf_gcc/linked_maps2.bpf.o':
Cannot allocate memory (12)
==2125110== Invalid free() / delete / delete[] / realloc()
==2125110==    at 0x484B0C4: free (vg_replace_malloc.c:884)
==2125110==    by 0x17F8AB: bpf_linker__free (linker.c:204)
==2125110==    by 0x12833C: do_object (gen.c:1608)
==2125110==    by 0x12CDAB: cmd_select (main.c:206)
==2125110==    by 0x129B53: do_gen (gen.c:2332)
==2125110==    by 0x12CDAB: cmd_select (main.c:206)
==2125110==    by 0x12DB9E: main (main.c:539)
==2125110==  Address 0xda4b420 is 0 bytes after a block of size 0 free'd
==2125110==    at 0x484B027: free (vg_replace_malloc.c:883)
==2125110==    by 0x484D6F8: realloc (vg_replace_malloc.c:1451)
==2125110==    by 0x181FA3: extend_sec (linker.c:1117)
==2125110==    by 0x182326: linker_append_sec_data (linker.c:1201)
==2125110==    by 0x1803DC: bpf_linker__add_file (linker.c:453)
==2125110==    by 0x12829E: do_object (gen.c:1593)
==2125110==    by 0x12CDAB: cmd_select (main.c:206)
==2125110==    by 0x129B53: do_gen (gen.c:2332)
==2125110==    by 0x12CDAB: cmd_select (main.c:206)
==2125110==    by 0x12DB9E: main (main.c:539)
==2125110==  Block was alloc'd at
==2125110==    at 0x484876A: malloc (vg_replace_malloc.c:392)
==2125110==    by 0x484D6EB: realloc (vg_replace_malloc.c:1451)
==2125110==    by 0x181FA3: extend_sec (linker.c:1117)
==2125110==    by 0x182326: linker_append_sec_data (linker.c:1201)
==2125110==    by 0x1803DC: bpf_linker__add_file (linker.c:453)
==2125110==    by 0x12829E: do_object (gen.c:1593)
==2125110==    by 0x12CDAB: cmd_select (main.c:206)
==2125110==    by 0x129B53: do_gen (gen.c:2332)
==2125110==    by 0x12CDAB: cmd_select (main.c:206)
==2125110==    by 0x12DB9E: main (main.c:539)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/109256] Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12)
  2023-03-23  4:06 [Bug target/109256] New: Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12) james.hilliard1 at gmail dot com
@ 2023-03-23  4:11 ` pinskia at gcc dot gnu.org
  2023-03-23  4:21 ` james.hilliard1 at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-23  4:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109256

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Even a bad input should cause an error reported rather than a double free. So
you should at least report it to libbpf too

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/109256] Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12)
  2023-03-23  4:06 [Bug target/109256] New: Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12) james.hilliard1 at gmail dot com
  2023-03-23  4:11 ` [Bug target/109256] " pinskia at gcc dot gnu.org
@ 2023-03-23  4:21 ` james.hilliard1 at gmail dot com
  2023-03-28  3:10 ` james.hilliard1 at gmail dot com
  2023-03-29  0:13 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: james.hilliard1 at gmail dot com @ 2023-03-23  4:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109256

--- Comment #2 from James Hilliard <james.hilliard1 at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> Even a bad input should cause an error reported rather than a double free.
> So you should at least report it to libbpf too

libbpf bug report:
https://lore.kernel.org/bpf/CADvTj4o7ZWUikKwNTwFq0O_AaX+46t_+Ca9gvWMYdWdRtTGeHQ@mail.gmail.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/109256] Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12)
  2023-03-23  4:06 [Bug target/109256] New: Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12) james.hilliard1 at gmail dot com
  2023-03-23  4:11 ` [Bug target/109256] " pinskia at gcc dot gnu.org
  2023-03-23  4:21 ` james.hilliard1 at gmail dot com
@ 2023-03-28  3:10 ` james.hilliard1 at gmail dot com
  2023-03-29  0:13 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: james.hilliard1 at gmail dot com @ 2023-03-28  3:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109256

James Hilliard <james.hilliard1 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from James Hilliard <james.hilliard1 at gmail dot com> ---
Fix has been merged upstream in bpf-next:
https://lore.kernel.org/bpf/20230328004738.381898-3-eddyz87@gmail.com/
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=d08ab82f59d55b0e5acfeb453081278dfc33f232

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/109256] Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12)
  2023-03-23  4:06 [Bug target/109256] New: Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12) james.hilliard1 at gmail dot com
                   ` (2 preceding siblings ...)
  2023-03-28  3:10 ` james.hilliard1 at gmail dot com
@ 2023-03-29  0:13 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-29  0:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109256

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |MOVED

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Not a GCC bug in the end, so changed to move.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-29  0:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-23  4:06 [Bug target/109256] New: Error: failed to link 'linked_maps2.bpf.o': Cannot allocate memory (12) james.hilliard1 at gmail dot com
2023-03-23  4:11 ` [Bug target/109256] " pinskia at gcc dot gnu.org
2023-03-23  4:21 ` james.hilliard1 at gmail dot com
2023-03-28  3:10 ` james.hilliard1 at gmail dot com
2023-03-29  0:13 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).