llvm / llvm/llvm-project

[LLDB] ValueObject::Cast does not correctly handle casts to Reference types.

Open
#174,867 2 comments 0 reactions 0 assignees View on GitHub
lldb
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

If I have a plain integer variable, declared "int a;", if I try to use DIL to cast it to an 'int&', I get an error (from ValueObject::Cast) complaining that I'm trying to cast to a type that's larger than the original type (the original type was a 4-byte int, and the new type is an 8-byte address).

However, if I try to cast arr_1d, which is an array of 4 ints to an 'int &', it passes the size test (an array of 4 ints is 16 bytes long), but the casting code then ends up reading the first two bytes of the array and treating that as the address, rather than getting the actual address of the array. (Note the first value in the array is 1, and the second value in the array is 2. Adjusting for endianness, we end up with the "address" 0x0000000200000001 , which is completely wrong. but which LLDB then tries to read from, resulting in a read error.

(See conversation/discussion in PR/170332 for more context.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.