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

            Bug ID: 121070
           Summary: bounds sanitizer should instrument arrays inside a
                    structure
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qinzhao at gcc dot gnu.org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
  Target Milestone: ---

currently, the bounds sanitizer fails to instrument arrays inside a structure. 

for example:

struct inside_array {
  int b;
  int c[10]; 
} *p_array;

void __attribute__((__noinline__)) setup ( )
{
  p_array
    = (struct inside_array *) __builtin_malloc (sizeof (struct inside_array));

  return;
}

void __attribute__((__noinline__)) test (int index)
{
  p_array->c[index] = 2;
}

int main(int argc, char *argv[])
{
  setup ();   
  test (11);
  return 0;
}

$ gcc t.c -O -g -fsanitize=bounds -o ./t.exe -fdump-tree-original
$ ./t.exe
$ egrep UBSAN t.c.006t.original
$

should we instrument such array reference inside a structure?

Reply via email to