hugsy / gef

GEF (GDB Enhanced Features) - a modern experience for GDB with advanced debugging capabilities for exploit devs & reverse engineers on Linux
https://hugsy.github.io/gef
MIT License
7.02k stars 739 forks source link

variable name causes problems #1123

Open Len101218 opened 4 months ago

Len101218 commented 4 months ago

GEF+GDB version

GEF: (Standalone)
Blob Hash(/usr/share/gef/gef.py): c713c62efd950a24413b0834d9e8fd3563ba114f
SHA256(/usr/share/gef/gef.py): 12881b1d42fb490ca72896099daf5c128c7c7382be0779c8f8f7db3a9161ab6f
GDB: 14.2
GDB-Python: 3.12

Operating System

Arch Linux

Describe the issue you encountered

Using some variable with the name tcache in the c code and compile with debug symbols, will cause errors in the output of heap bins. I am not sure, if this problem also occurs for other variable names.

Do you read the docs and look at previously closed issues/PRs for similar cases?

No

Architecture impacted

Describe your issue. Without a proper reproduction step-by-step, your issue will be ignored.

Compiling with -g causes problems when using command heap bins:

#include <stdlib.h>
int main(){
  void * tcache[7];
  for(int i = 0; i < 7; i ++){
    tcache[i] = malloc(0x80);
    *(char *)tcache[i] = i+1;
  }
  for(int i = 0 ; i < 7 ; i++){
      free(tcache[i]);
  }
}

But renaming tcache variable, will fix the problem again.

Minimalist test case

Use this field for a minimal code to compile and spot the issue:

// compile with gcc -g
#include <stdlib.h>
int main(){
  void * tcache[7];
  for(int i = 0; i < 7; i ++){
    tcache[i] = malloc(0x80);
    *(char *)tcache[i] = i+1;
  }
  for(int i = 0 ; i < 7 ; i++){
      free(tcache[i]);
  }
}    

Additional context?

image