Skip to content

LLDB error while debugging the binary generated with the -O3: extracting data from value failedΒ #111202

@edumoot

Description

@edumoot

In the context of LLVM versions 19.1.0, 18.1.8, and 17.0.6, we encountered the following error when trying to print the variable l_21 at line 17: error: Couldn't materialize: couldn't get the value of variable l_21: extracting data from value failed error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression. Godblot link is here. GDB treats l_21 as a triple pointer.

We reproduce it in LLVM 19.1.0, 18.1.9, and 17.0.6.

 clang -g -O3 -o d2_O3.out d2.c

(lldb) file d2_O3.out
(lldb) b 17
Breakpoint 1: where = d2_O3.out`main + 16 [inlined] func_1 at d2.c:17:23, address = 0x0000000000001140
(lldb) r

* thread #1, name = 'd2_O3.out', stop reason = breakpoint 1.1
    frame #0: 0x0000555555555140 d2_O3.out`main at d2.c:17:23
   14  	                uint8_t l_13[5];
   15  	                for (g_14 = 0; (g_14 <= 4); g_14 += 1) {
   16  	                    int32_t *l_21[8][6][2] = {};
-> 17  	                    (*g_17) |= 0;
   18  	                    if ((*g_17)) {
   19  	                        continue;
   20  	                    }
(lldb) fr v
(int32_t *[8][6][2]) l_21 = <extracting data from value failed>
(lldb) p l_21
error: Couldn't materialize: couldn't get the value of variable l_21: extracting data from value failed
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) p ***l_21
error: Couldn't materialize: couldn't get the value of variable l_21: extracting data from value failed
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) p ****l_21
error: Couldn't materialize: couldn't get the value of variable l_21: extracting data from value failed
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression

GDB treats l_21 as a triple pointer.

$ gdb 
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
...
file d2_O3.out
(gdb) b 17
(gdb) r
[...]
Breakpoint 1, func_1 () at d2.c:17
17	                    (*g_17) |= 0;
(gdb) p l_21
$1 = {{{0x0, 0x0}, {0x0, 0xb1}, {0x75e9ef3fb178, 0x602d242a8190}, {0x8, 0x602d242b7130}, {0x602d242b7130, 0x602d242b7330}, {0x602d242a81a8, 0x602d242b7150}}, {{0x602d242b7130, 0x602d242b7330}, {
      0x602d242a81a8, 0x0}, {0x0, 0x602d2429d110}, {0x11, 0x1e}, {0x602d23acc6d0, 0x1}, {0x602d242b7340, 0x602d23d830e0}}, {{0x602b217eff9c, 0x21}, {0x75e9ef3fa0c0, 0x100000001}, {0x602d24341e20, 0x21}, 
    {0x75e9ef3fa0c0, 0x100000001}, {0x602d243417c0, 0x51}, {0x75e9eee03b60, 0x75e9eee03b60}}, {{0x676e69727473, 0x602d243429f0}, {0x836d1, 0x21}, {0x602d23acc750, 0x602d23acc580}, {0x50, 0x91}, {
      0x602d239f2400, 0x602d23a32190}, {0x602d23acc670, 0x6}}, {{0x676e69727473, 0x5003b}, {0x40, 0x50}, {0x602b217efdbc, 0x3b}, {0x3b, 0x292a5d5d3a6b6e61}, {0x602d23acc6c0, 0x0}, {0x3e27223d5e5b2800, 
      0x292b5d}}, {{0x90, 0xa0}, {0x602b00000019, 0x602d23acc6f8}, {0x6, 0x676e69727473}, {0x30, 0x602d242913c0}, {0x8, 0x602d242d6db0}, {0x602d242d6db0, 0x602d242d6fb0}}, {{0x602d242913d8, 
      0x602d242d6dd0}, {0x602d242d6db0, 0x602d242d6fb0}, {0x602d242913d8, 0x0}, {0x0, 0x0}, {0xa0, 0xf1}, {0x602d23b129e0, 0x602d23b2f8d0}}, {{0x6c623a5b5b28292b, 0x292a5d5d3a6b6e61}, {
      0x623a5b5b28293d28, 0x2a5d5d3a6b6e616c}, {0x3e27223d5e5b2829, 0x292b5d}, {0x602d23acc860, 0x21}, {0x602d23c5f890, 0x602d23acbf30}, {0x70, 0x60}}}
(gdb) p *l_21
$2 = {{0x0, 0x0}, {0x0, 0x31}, {0x697274735f79656b, 0x3a676e616c2e676e}, {0x696c6867006c0037, 0x746867}, {0x602d23aae9a0, 0x31}, {0x602d235e11c0, 0x602d235ae460}}
(gdb) p **l_21
$3 = {0x0, 0x0}
(gdb) p ***l_21
$4 = (int32_t *) 0x0
(gdb) p ****l_21
Cannot access memory at address 0x0

`cat d2.c1

#include "stdint.h"

static int32_t g_4 = 1L;
static int32_t g_10 = 0xF3C34EEAL;
static int32_t g_14 = 0;
static int32_t g_18 = 0x0A3267E6L;
static int32_t * volatile g_17 = &g_18;

static uint8_t func_1(void) {
    for (g_4 = 0; (g_4 >= 0); g_4 = (g_4 + 6)) {
        int i;
        for (i = 0; i < 3; i++) {
            for (g_10 = 16; (g_10 >= (-19)); g_10--) {
                uint8_t l_13[5];
                for (g_14 = 0; (g_14 <= 4); g_14 += 1) {
                    int32_t *l_21[8][6][2] = {};
                    (*g_17) |= 0;
                    if ((*g_17)) {
                        continue;
                    }
                }
            }
        }
    }
    return 0; 
}

int main(void) {
    func_1();
    return 0; 
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions