https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64057
Bug ID: 64057 Summary: Overlapping memcpy generated for array assignment Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: tobiasu at tmux dot org Created attachment 34099 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34099&action=edit memcpy wrapper with overlap detection The Ada front end generates a overlapping memcpy call for some array assignments. Using a strict version of memcpy that checks for overlap breaks gnat 4.8 and 4.9 on my Linux and OpenBSD test systems. Other applications compiled with gnat may be affected as well. Easy way to reproduce: Build gnat and ^C once gcc/ada/bldtools/sinfo is generated. Build the attached memcpy wrapper or patch your libc with checks. $ cd $BUILD/gcc/ada/bldtools/sinfo $ LD_PRELOAD=./memcpy.so gdb ./xsinfo GNU gdb (GDB) 7.8.1 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./xsinfo...(no debugging symbols found)...done. (gdb) run Starting program: /home/tulmer/tmp/gcc/src/gcc-build/gcc/ada/bldtools/sinfo/xsinfo warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? Check for field name consistency OK Check for function consistency OK Check for missing functions OK Check for set procedure consistency OK Check for missing set procedures OK Check pragma Inlines are all for existing subprograms memcpy(0x6c125c, 0x6c1260, 14) dest=Set_ABE_Is_Certainbs src=ABE_Is_Certainbs Program received signal SIGABRT, Aborted. 0x00007ffff786aa97 in raise () from /usr/lib/libc.so.6 (gdb) bt #0 0x00007ffff786aa97 in raise () from /usr/lib/libc.so.6 #1 0x00007ffff786be6a in abort () from /usr/lib/libc.so.6 #2 0x00007ffff7bda879 in memcpy () from ./memcpy.so #3 0x000000000042c20e in ada.strings.unbounded.set_unbounded_string () #4 0x0000000000443b31 in gnat.spitbol.patterns.xmatch () #5 0x000000000044488b in gnat.spitbol.patterns.match () #6 0x000000000040afd0 in csinfo () #7 0x000000000041bb69 in xsinfo () Let me know if you need more info