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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> While building the ada compiler the address sanitizer detecst an
> heap-buffer-overflow in namet.adb line 157:
> 
>  Index : constant Int   := Name_Entries.Table (Id).Name_Chars_Index;
> 
> because Id=-399990000

The table is declared like this though:

   package Name_Entries is new Table.Table (
     Table_Component_Type => Name_Entry,
     Table_Index_Type     => Valid_Name_Id'Base,
     Table_Low_Bound      => First_Name_Id,
     Table_Initial        => Alloc.Names_Initial,
     Table_Increment      => Alloc.Names_Increment,
     Table_Name           => "Name_Entries");

with:

   First_Name_Id : constant Name_Id := Names_Low_Bound + 2;
   --  Subscript of first entry in names table

   subtype Valid_Name_Id is Name_Id range First_Name_Id .. Name_Id'Last;
   --  All but No_Name and Error_Name

and:

  Names_Low_Bound : constant := -399999999;

so Id = -399990000 is well within the allowed range (9997 0-based index).

Are you sure that Id is not equal to Names_Low_Bound, which would be the -2
0-based index and, therefore, -32 bytes since the size of Name_Entry is 16?

On the other hand, this would mean that:

      pragma Assert (Is_Valid_Name (Id));

would have triggered because the compiler is supposed to be configured with
assertions enabled on the mainline, so I'm quite at a loss here.

It looks like the address sanitizer is miscompiling the Ada compiler?

Reply via email to