https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77535
Bug ID: 77535 Summary: GNAT.Perfect_Hash_Generators access invalid memory with non-1-based strings Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: fw at gcc dot gnu.org Target Milestone: --- Created attachment 39585 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39585&action=edit phg2.adb Natasha Kerensikova reported this to comp.lang.ada. The attached file was downloaded from: http://users.instinctive.eu/nat/phg/ When running it under valgrind, I get: ==4196== Invalid read of size 1 ==4196== at 0x5032D23: ??? (in /usr/lib/x86_64-linux-gnu/libgnat-4.9.so.1) ==4196== by 0x5035254: gnat__perfect_hash_generators__compute (in /usr/lib/x86_64-linux-gnu/libgnat-4.9.so.1) ==4196== by 0x402F3B: _ada_phg2 (in /tmp/g/phg2) ==4196== by 0x402DA5: main (in /tmp/g/phg2) ==4196== Address 0x5e61837 is 23 bytes after a block of size 16 alloc'd ==4196== at 0x4C28C20: malloc (vg_replace_malloc.c:296) ==4196== by 0x507F403: __gnat_malloc (in /usr/lib/x86_64-linux-gnu/libgnat-4.9.so.1) ==4196== by 0x5033413: ??? (in /usr/lib/x86_64-linux-gnu/libgnat-4.9.so.1) ==4196== by 0x5035098: gnat__perfect_hash_generators__compute (in /usr/lib/x86_64-linux-gnu/libgnat-4.9.so.1) ==4196== by 0x402F3B: _ada_phg2 (in /tmp/g/phg2) ==4196== by 0x402DA5: main (in /tmp/g/phg2) Others have reported a segfault. This is apparently due to GNAT.Perfect_Hash_Generators not dealing properly with non-1-based strings.