* Does gdb initialize uninitialized variables? @ 2022-02-21 9:44 Edgar Mobile 2022-02-21 17:33 ` Ruslan Kabatsayev 0 siblings, 1 reply; 4+ messages in thread From: Edgar Mobile @ 2022-02-21 9:44 UTC (permalink / raw) To: gdb Greetings, I currently try to find a bug that might be caused by uninitialized variables/memory. But it never appears when I use gdb. Does gdb change how memory is initialized in any way, be it on stack or via new/malloc? Regards ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Does gdb initialize uninitialized variables? 2022-02-21 9:44 Does gdb initialize uninitialized variables? Edgar Mobile @ 2022-02-21 17:33 ` Ruslan Kabatsayev 2022-02-22 21:30 ` Edgar Mobile 0 siblings, 1 reply; 4+ messages in thread From: Ruslan Kabatsayev @ 2022-02-21 17:33 UTC (permalink / raw) To: Edgar Mobile; +Cc: gdb Hi, On Mon, 21 Feb 2022 at 12:45, Edgar Mobile via Gdb <gdb@sourceware.org> wrote: > > Greetings, > > I currently try to find a bug that might be caused by uninitialized variables/memory. But it never appears when I use gdb. Does gdb change how memory is initialized in any way, be it on stack or via new/malloc? Memory-related bugs that don't happen when using GDB but do without GDB are often caused by GDB disabling ASLR. This is usually useful for reproducibility of debugging sessions, but may indeed make address space layout too predictable and fail to reproduce a bug. Try using the GDB command "set disable-randomization off" (without quotes) to undo this behavior and thus start your program in a normal, randomized, environment. Besides, if your problem is indeed with uninitialized variables, you might find Valgrind memory checker more useful than a debugger. > > Regards Regards, Ruslan ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Does gdb initialize uninitialized variables? 2022-02-21 17:33 ` Ruslan Kabatsayev @ 2022-02-22 21:30 ` Edgar Mobile 2022-02-22 22:20 ` Martin Simmons 0 siblings, 1 reply; 4+ messages in thread From: Edgar Mobile @ 2022-02-22 21:30 UTC (permalink / raw) To: Ruslan Kabatsayev; +Cc: gdb I tried it as the very first command even before run. Any more ideas? (tx already) ________________________________ From: Ruslan Kabatsayev <b7.10110111@gmail.com> Sent: Monday, February 21, 2022 5:33 PM To: Edgar Mobile <heideggm@hotmail.com> Cc: gdb@sourceware.org <gdb@sourceware.org> Subject: Re: Does gdb initialize uninitialized variables? Hi, On Mon, 21 Feb 2022 at 12:45, Edgar Mobile via Gdb <gdb@sourceware.org> wrote: > > Greetings, > > I currently try to find a bug that might be caused by uninitialized variables/memory. But it never appears when I use gdb. Does gdb change how memory is initialized in any way, be it on stack or via new/malloc? Memory-related bugs that don't happen when using GDB but do without GDB are often caused by GDB disabling ASLR. This is usually useful for reproducibility of debugging sessions, but may indeed make address space layout too predictable and fail to reproduce a bug. Try using the GDB command "set disable-randomization off" (without quotes) to undo this behavior and thus start your program in a normal, randomized, environment. Besides, if your problem is indeed with uninitialized variables, you might find Valgrind memory checker more useful than a debugger. > > Regards Regards, Ruslan ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Does gdb initialize uninitialized variables? 2022-02-22 21:30 ` Edgar Mobile @ 2022-02-22 22:20 ` Martin Simmons 0 siblings, 0 replies; 4+ messages in thread From: Martin Simmons @ 2022-02-22 22:20 UTC (permalink / raw) To: Edgar Mobile; +Cc: b7.10110111, gdb I've sometimes seen different layout of the stack when running under gdb because it changes the environment and converts argv[0] to an absolute path. You could try running the program without gdb and then attach gdb to it from a different shell. If the program crashes before you have time to attach gdb, then try adding a call to sleep() in main() to delay it. __Martin >>>>> On Tue, 22 Feb 2022 21:30:26 +0000, Edgar Mobile via Gdb said: > > I tried it as the very first command even before run. Any more ideas? (tx already) > > ________________________________ > From: Ruslan Kabatsayev <b7.10110111@gmail.com> > Sent: Monday, February 21, 2022 5:33 PM > To: Edgar Mobile <heideggm@hotmail.com> > Cc: gdb@sourceware.org <gdb@sourceware.org> > Subject: Re: Does gdb initialize uninitialized variables? > > Hi, > > On Mon, 21 Feb 2022 at 12:45, Edgar Mobile via Gdb <gdb@sourceware.org> wrote: > > > > Greetings, > > > > I currently try to find a bug that might be caused by uninitialized variables/memory. But it never appears when I use gdb. Does gdb change how memory is initialized in any way, be it on stack or via new/malloc? > > Memory-related bugs that don't happen when using GDB but do without > GDB are often caused by GDB disabling ASLR. This is usually useful for > reproducibility of debugging sessions, but may indeed make address > space layout too predictable and fail to reproduce a bug. Try using > the GDB command "set disable-randomization off" (without quotes) to > undo this behavior and thus start your program in a normal, > randomized, environment. > > Besides, if your problem is indeed with uninitialized variables, you > might find Valgrind memory checker more useful than a debugger. > > > > > Regards > > Regards, > Ruslan > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-22 22:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-02-21 9:44 Does gdb initialize uninitialized variables? Edgar Mobile 2022-02-21 17:33 ` Ruslan Kabatsayev 2022-02-22 21:30 ` Edgar Mobile 2022-02-22 22:20 ` Martin Simmons
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).