Lv_event_dsc_t mutated by somewhere but I can't find where

Hi,

I use lv_obj_add_event_cb to register event callbacks and get lv_event_dsc_ts back. I suppose the lv_event_dsc_t returned is valid before I remove the callback, and the object is allocated by lvgl that will last after my calling function exits.

However, in my particular code below, I observed that at some time after I get lv_event_dsc_t , the content in it is mutated. I don’t know who is mutating it. I’ll show you the complete code.

#include <lvgl.h>
#include <LilyGoLib.h>

// copied from lv_event.c
typedef struct _lv_event_dsc_t {
    lv_event_cb_t cb;
    void * user_data;
    lv_event_code_t filter : 8;
} lv_event_dsc_t;

void d(lv_event_dsc_t *dsc);

void input_number() {
    auto number = lv_obj_create(lv_layer_top());
    lv_event_dsc_t *dsc = lv_obj_add_event_cb(number, [](lv_event_t *e) {}, LV_EVENT_READY, nullptr);
    d(dsc); // get `dsc 1070544804 { 31, 0 }`
    // the following line is necessary for the issue to happen
    lv_event_dsc_t *dsc_cancel = lv_obj_add_event_cb(number, [](lv_event_t *e) {}, LV_EVENT_CANCEL, nullptr);
    d(dsc); // get `dsc 1070544804 { 31, 0 }` also
    lv_timer_create([](_lv_timer_t *t){
        d((lv_event_dsc_t*)t->user_data);   // get `dsc 1070544804 { 0, 208 }`
    }, 1000, dsc);
}

void d(lv_event_dsc_t *dsc) {
    Serial.printf("dsc %d { %d, %d }\n", dsc, dsc->filter, dsc->user_data);
}

The main code calls input_number, let the object show, and I do nothing with the screen. I expect each line in the output to be the same, but actually it changes after 1 second.

I can’t figure out why. An interesting point is that the line I remarked in code above is necessary for the issue to happen. If I remove it, all lines becomes the same.

Can anyone help?