This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fixup gdb.python/py-value.exp for bare-metal aarch64-elf


On 10/07/2016 05:23 AM, Yao Qi wrote:
On Thu, Oct 6, 2016 at 5:27 PM, Luis Machado <lgustavo@codesourcery.com> wrote:
I noticed that testing aarch64-elf gdb with a physical board
ran into issues with gdb.python/py-value.exp. Further investigation showed
that we were actually trying to dereference a NULL pointer (argv) when trying
to access argv[0].

Being bare-metal, argv is not guaranteed to be there. So we need to make sure
argv is sane before accessing argv[0].

After fixing that, i noticed we were assuming a value of 1 for argc, which is
also not true, as i see 0 in my tests.

If I understand C standard
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf correctly,
"argv" can't be NULL.

5.1.2.2.1 Program startup
...
 The value of argc shall be nonnegative.
 argv[argc] shall be a null pointer.

The first one implies that argc can be zero, and the second one implies
argv can't be NULL.  In this case, argc is zero, so argv[0] can be
dereferenced.


Ah, that makes sense indeed. Let me check the startup code and i'll get back to this patch (that may not be needed then).

Thanks,
Luis


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]