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

            Bug ID: 93850
           Summary: 'stack smashing detected' in the special index for an
                    array
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, I am developing a random c generation tool to find c compiler bugs.

I found an interesting code that compiles successfully but get a "stack
smashing detected" error when executing it.

The c code is 

void foo(int* a ) {
  a[2]=1;
}
int main (int argc, char* argv[]) {
  int array[] = {0};
  foo(array);
  return 0;
}

My compile command is "gcc test.cc" and it succeeds. Then I execute it using
"./a.out" but I got a 

"*** stack smashing detected ***: ./a.out terminated 
Aborted" 

error. 

I know we should initialize an array before using it. But the most interesting
thing is that only an index of 2 in an array can trigger the error, other index
is fine for execution.

I test the code in GCC 5.4.0 in ubuntu 16.04.

Reply via email to