[Bug 35860] New: displaying some long double values causes lldb to crash

Bug ID 35860
Summary displaying some long double values causes lldb to crash
Product lldb
Version unspecified
Hardware PC
OS All
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter oliver@apple.com
CC llvm-bugs@lists.llvm.org

If I have something along the lines of:

  union {
    struct {
      int x;
      int y;
      int node_index;
    } as_point;
    long double as_number;
  } data;
  data.as_point.x = 0;
  data.as_point.y = 0;
  data.as_point.node_index = 512;

and pause after assigning to node_index, then try to display the struct:

p data

lldb crashes. I've reduced this to the problem being the display of the long
double, specifically it seems to be going wrong when the mantissa is zero but
the exponent in non-zero. Given the wonkiness of long double on x86 I assume
this is incorrect handling of a denormal (pseudo-denormal? I was reading some
of the docs on it and that appears to be a thing #wat).

It's a real problem in Xcode as Xcode auto displays the values of all locals
and so lldb crashes whenever this happens. I can work around this if I know it
may happen in a given function by manually setting the display type to
hex/binary/anything-other-than-default.

labath@google.com changed bug 35860

Comment # 1 on bug 35860 from labath@google.com

Actually, this is a a special case of an "unnormal" value :D
<[https://en.wikipedia.org/wiki/Extended_precision#x86_Extended_Precision_Format](https://en.wikipedia.org/wiki/Extended_precision#x86_Extended_Precision_Format)>.

I have a proposed fix for this in <[https://reviews.llvm.org/D41868](https://reviews.llvm.org/D41868)>