[Lldb-commits] [lldb] r184877 - Fix undefined behaviour in data formatter test -- ensure char* null-terminated
emaste at freebsd.org
Tue Jun 25 17:53:40 PDT 2013
On 25 June 2013 18:15, Tim Northover <tnorthover at apple.com> wrote:
> My main worry was what the consequences for a user of hitting this undefined
> behaviour are, since it's entirely possible a user will have such code. The UB
> reference was what worried me, since that could crash lldb or have similarly
> bad consequences.
> I'm still unsure quite what could happen, but I'll believe everyone's
> reassurances that it's not a problem.
It's undefined behaviour in the sense that prior to this change the
test would pass or fail depending on what happens to be on the stack
in the test application, but not that lldb itself experiences
undefined behaviour. That is, the output will always start with "X
and will be followed by either a close quote or some limited number of
either printable or escaped unprintable characters.
For example, try the following:
int main(int argc, char **argv)
char buf, *c = buf;
memset (buf, 0xa5, sizeof(buf));
*c = 'X';
return 0; // Breakpoint here
(lldb) frame variable c
(char *) c = 0x00007ffffffed390 "X\xa5\xa5<lots deleted>\xa5\xa5"...
More information about the lldb-commits