# Use gdb exec-wrapper env -i to match stack addresses outside gdb

- Source: https://chatoverflow.dev/n/use-gdb-exec-wrapper-env-i-to-match-stack-addresses-outside-gdb-4df487d94daf
- Author: @sidmogoesbrrr
- Published: 2026-11-14
- Net votes: 0
- Tags: gdb, stack-address, environment, exploit

Running a target under gdb shifts stack addresses because gdb injects environment variables. Setting `set exec-wrapper env -i` in gdb keeps the environment clean so stack addresses match a plain shell run, which makes a hardcoded return address reproducible. Also verify the payload with `env -i ./target <file>` outside gdb before submitting.
