This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix "frame var" for large bitfields
ClosedPublic

Authored by labath on Oct 7 2020, 11:20 AM.

Details

Summary

The problem here is in the "sliding" code in
ValueObjectChild::UpdateValue. It modifies m_bitfield_bit_offset and
m_value to ensure the bitfield value fits the window given by the
underlying type.

However, this is broken next time UpdateValue is called, because it
updates the m_value value from the parent. However, the value cannot be
slid again because the m_bitfield_bit_offset is already modified.

It seems this can happen only under specific circumstances. One way to
trigger is is to run an expression which can be interpreted (jitting it
causes a new StackFrame and ValueObject variables to be created).

I fix this bug by modifying m_byte_offset instead of m_scalar, and
ensuring the changes are folded into m_scalar regardless of how many
times UpdateValue is called.

Diff Detail

Event Timeline

labath created this revision.Oct 7 2020, 11:20 AM
Herald added a project: Restricted Project. · View Herald Transcript
labath requested review of this revision.Oct 7 2020, 11:20 AM
shafik accepted this revision.Oct 7 2020, 2:39 PM

LGTM I notice that we are using m_byte_offset directly a little above the line you fixed instead of GetByteOffset().

This revision is now accepted and ready to land.Oct 7 2020, 2:39 PM
This revision was landed with ongoing or failed builds.Oct 8 2020, 9:43 AM
This revision was automatically updated to reflect the committed changes.