lvgl: Access Violation Writing Error

I am not sure what is causing this error. It is internal to LVGL as it happens when I move a slider.

This is using SDL so all of the display and indev related bits are internal to LVGL.

Here is the debugging stack trace from Visual Studio

_lib_lvgl.dll!lv_event_send(lv_event_list_t * list=0x0000021d173df588, _lv_event_t * e=0x000000f7f4fee708, bool preprocess=false) Line 72
	at *****\lv_cpython\src\lvgl\src\misc\lv_event.c(72)
_lib_lvgl.dll!event_send_core(_lv_event_t * e=0x000000f7f4fee708) Line 310
	at *****\lv_cpython\src\lvgl\src\core\lv_obj_event.c(310)
_lib_lvgl.dll!lv_obj_send_event(_lv_obj_t * obj=0x0000021d1789dc90, lv_event_code_t event_code=LV_EVENT_VALUE_CHANGED, void * param=0x0000000000000000) Line 64
	at *****\lv_cpython\src\lvgl\src\core\lv_obj_event.c(64)
_lib_lvgl.dll!update_knob_pos(_lv_obj_t * obj=0x0000021d1789dc90, bool check_drag=true) Line 476
	at *****\lv_cpython\src\lvgl\src\widgets\slider\lv_slider.c(476)
_lib_lvgl.dll!lv_slider_event(const _lv_obj_class_t * class_p=0x00007ffbc9933560, _lv_event_t * e=0x000000f7f4fee9a8) Line 140
	at *****\lv_cpython\src\lvgl\src\widgets\slider\lv_slider.c(140)
_lib_lvgl.dll!lv_obj_event_base(const _lv_obj_class_t * class_p=0x0000000000000000, _lv_event_t * e=0x000000f7f4fee9a8) Line 89
	at *****\lv_cpython\src\lvgl\src\core\lv_obj_event.c(89)
_lib_lvgl.dll!event_send_core(_lv_event_t * e=0x000000f7f4fee9a8) Line 307
	at *****\lv_cpython\src\lvgl\src\core\lv_obj_event.c(307)
_lib_lvgl.dll!lv_obj_send_event(_lv_obj_t * obj=0x0000021d1789dc90, lv_event_code_t event_code=LV_EVENT_PRESSING, void * param=0x0000021d16aa2430) Line 64
	at *****\lv_cpython\src\lvgl\src\core\lv_obj_event.c(64)
_lib_lvgl.dll!indev_proc_press(_lv_indev_t * indev=0x0000021d16aa2430) Line 1083
	at *****\lv_cpython\src\lvgl\src\indev\lv_indev.c(1083)
_lib_lvgl.dll!indev_pointer_proc(_lv_indev_t * i=0x0000021d16aa2430, lv_indev_data_t * data=0x000000f7f4feeab8) Line 557
	at *****\lv_cpython\src\lvgl\src\indev\lv_indev.c(557)
_lib_lvgl.dll!lv_indev_read_timer_cb(_lv_timer_t * timer=0x0000021d17398eb0) Line 207
	at *****\lv_cpython\src\lvgl\src\indev\lv_indev.c(207)
_lib_lvgl.dll!lv_timer_exec(_lv_timer_t * timer=0x0000021d17398eb0) Line 348
	at *****\lv_cpython\src\lvgl\src\misc\lv_timer.c(348)
_lib_lvgl.dll!lv_timer_handler() Line 114
	at *****\lv_cpython\src\lvgl\src\misc\lv_timer.c(114)
_lib_lvgl.dll!lv_task_handler() Line 47
	at *****\lv_cpython\src\lvgl\src\lv_api_map.h(47)
_lib_lvgl.dll!py_lv_task_handler() Line 7169
	at *****\lv_cpython\build\temp.win-amd64-cpython-311\dllmain.c(7169)
libffi-8.dll!00007ffc6c6e4771()
libffi-8.dll!00007ffc6c6e4493()
libffi-8.dll!00007ffc6c6e42c2()
_ctypes.pyd!_call_function_pointer(int flags=0x00001101, int(*)() pProc=0x00007ffbc94f4920, void * * avalues=0x000000f7f4feee60, _ffi_type * * atypes=0x0000021d17366fd0, _ffi_type * restype, void * resmem=0x000000f7f4feee60, int argcount=0x00000000, int) Line 926
	at D:\a\1\s\Modules\_ctypes\callproc.c(926)
_ctypes.pyd!_ctypes_callproc(int(*)() pProc=0x00007ffbc94f4920, _object * argtuple, IUnknown * pIunk=0x0000000000000000, _GUID * iid=0x0000000000000000, int flags=0x00001101, _object * argtypes=0x00007ffbca01c5d8, _object * restype=0x0000021d17366fd0, _object * checker=0x0000000000000000) Line 1262
	at D:\a\1\s\Modules\_ctypes\callproc.c(1262)
_ctypes.pyd!PyCFuncPtr_call(PyCFuncPtrObject * self=0x0000021d1a1a29c0, _object * inargs=0x0000000000000000, _object * kwds=0x0000000000000000) Line 4201
	at D:\a\1\s\Modules\_ctypes\_ctypes.c(4201)
python311.dll!_PyObject_MakeTpCall(_ts * tstate=0x00007ffbca036960, _object * callable=0x0000021d1a1a29c0, _object * const * args=0x0000021d16d30110, __int64 nargs=0x0000000000000000, _object * keywords=0x0000000000000000) Line 216
	at D:\a\1\s\Objects\call.c(216)
[Inline Frame] python311.dll!_PyObject_VectorcallTstate(_ts *) Line 90
	at D:\a\1\s\Include\internal\pycore_call.h(90)
python311.dll!PyObject_Vectorcall(_object * callable=0x0000021d1a1a29c0, _object * const * args=0x0000021d16d30110, unsigned __int64 nargsf, _object * kwnames=0x0000000000000000) Line 299
	at D:\a\1\s\Objects\call.c(299)
python311.dll!_PyEval_EvalFrameDefault(_ts * tstate=0x00007ffbca036960, _PyInterpreterFrame * frame=0x0000021d16fb5900, int throwflag=0xca036960) Line 4778
	at D:\a\1\s\Python\ceval.c(4778)
[Inline Frame] python311.dll!_PyEval_EvalFrame(_ts *) Line 73
	at D:\a\1\s\Include\internal\pycore_ceval.h(73)
python311.dll!_PyEval_Vector(_ts * tstate=0x00007ffbca036960, PyFunctionObject * func, _object * locals, _object * const * args, unsigned __int64 argcount=0x0000000000000000, _object * kwnames=0x0000000000000000) Line 6443
	at D:\a\1\s\Python\ceval.c(6443)
python311.dll!PyEval_EvalCode(_object * co, _object * globals=0x0000021d16fb5900, _object * locals=0x0000021d16fb5900) Line 1155
	at D:\a\1\s\Python\ceval.c(1155)
python311.dll!run_eval_code_obj(_ts * tstate=0x00007ffbca036960, PyCodeObject * co=0x0000021d17322eb0, _object * globals=0x0000021d16fb5900, _object * locals=0x0000021d16fb5900) Line 1715
	at D:\a\1\s\Python\pythonrun.c(1715)
python311.dll!run_mod(_mod * mod, _object * filename, _object * globals=0x0000021d16fb5900, _object * locals=0x0000021d16fb5900, PyCompilerFlags * flags=0x000000f7f4fef610, _arena * arena=0x0000021d16edbb70) Line 1736
	at D:\a\1\s\Python\pythonrun.c(1736)
python311.dll!pyrun_file(_iobuf * fp=0x0000021d16b3afa0, _object * filename=0x0000021d16eecf10, int start, _object * globals=0x0000021d16fb5900, _object * locals=0x0000021d16fb5900, int closeit=0x00000001, PyCompilerFlags * flags=0x000000f7f4fef610) Line 1630
	at D:\a\1\s\Python\pythonrun.c(1630)
python311.dll!_PyRun_SimpleFileObject(_iobuf * fp=0x0000021d16b3afa0, _object * filename=0x0000021d16eecf10, int closeit=0x00000001, PyCompilerFlags * flags=0x000000f7f4fef610) Line 443
	at D:\a\1\s\Python\pythonrun.c(443)
python311.dll!_PyRun_AnyFileObject(_iobuf * fp=0x0000021d16b3afa0, _object * filename=0x0000021d16eecf10, int closeit=0x00000001, PyCompilerFlags * flags=0x000000f7f4fef610) Line 79
	at D:\a\1\s\Python\pythonrun.c(79)
python311.dll!pymain_run_file_obj(_object * program_name=0x0000021d16fb8fd0, _object * filename=0x0000021d16eecf10, int skip_source_first_line=0x00000000) Line 361
	at D:\a\1\s\Modules\main.c(361)
python311.dll!pymain_run_file(const PyConfig * config=0x00007ffbca01c9c0) Line 381
	at D:\a\1\s\Modules\main.c(381)
python311.dll!pymain_run_python(int * exitcode=0x000000f7f4fef780) Line 602
	at D:\a\1\s\Modules\main.c(602)
python311.dll!Py_RunMain() Line 682
	at D:\a\1\s\Modules\main.c(682)
python311.dll!Py_Main(int argc, wchar_t * * argv) Line 723
	at D:\a\1\s\Modules\main.c(723)
[Inline Frame] pythonw.exe!invoke_main() Line 118
	at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(118)
pythonw.exe!__scrt_common_main_seh() Line 288
	at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288)
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()

Here is the function where the event is occurring. I have marked the exact location the error is happening at.


lv_res_t lv_event_send(lv_event_list_t * list, lv_event_t * e, bool preprocess)
{
    if(list == NULL) return LV_RES_OK;

    uint32_t i = 0;
    for(i = 0; i < list->cnt; i++) {
        if(list->dsc[i].cb == NULL) continue;
        bool is_preprocessed = (list->dsc[i].filter & LV_EVENT_PREPROCESS) != 0;
        if(is_preprocessed != preprocess) continue;
        lv_event_code_t filter = list->dsc[i].filter & ~LV_EVENT_PREPROCESS;
        if(filter == LV_EVENT_ALL || filter == e->code) {
            e->user_data = list->dsc[i].user_data;
            list->dsc[i].cb(e);
            if(e->stop_processing) return LV_RES_OK;             <--- ERROR HAPPENS HERE

            /*Stop if the object is deleted*/
            if(e->deleted) return LV_RES_INV;

        }
    }
    return LV_RES_OK;

This is the code where the previos function was called from.


static lv_res_t event_send_core(lv_event_t * e)
{
    EVENT_TRACE("Sending event %d to %p with %p param", e->code, (void *)e->original_target, e->param);

    /*Call the input device's feedback callback if set*/
    lv_indev_t * indev_act = lv_indev_get_act();
    if(indev_act) {
        if(indev_act->feedback_cb) indev_act->feedback_cb(indev_act, e->code);
        if(e->stop_processing) return LV_RES_OK;
        if(e->deleted) return LV_RES_INV;
    }

    lv_obj_t * target = e->current_target;
    lv_res_t res = LV_RES_OK;
    lv_event_list_t * list = target->spec_attr ?  &target->spec_attr->event_list : NULL;

    res = lv_event_send(list, e, true);
    if(res != LV_RES_OK) return res;

    res = lv_obj_event_base(NULL, e);
    if(res != LV_RES_OK) return res;

    res = lv_event_send(list, e, false);     <-------------- CALLED FROM HERE
    if(res != LV_RES_OK) return res;

    lv_obj_t * parent = lv_obj_get_parent(e->current_target);
    if(parent && event_is_bubbled(e)) {
        e->current_target = parent;
        res = event_send_core(e);
        if(res != LV_RES_OK) return res;
    }

    return res;
}

the code where the previous function was called from


lv_res_t lv_obj_send_event(lv_obj_t * obj, lv_event_code_t event_code, void * param)
{
    if(obj == NULL) return LV_RES_OK;

    LV_ASSERT_OBJ(obj, MY_CLASS);

    lv_event_t e;
    e.current_target = obj;
    e.original_target = obj;
    e.code = event_code;
    e.user_data = NULL;
    e.param = param;
    e.deleted = 0;
    e.stop_bubbling = 0;
    e.stop_processing = 0;

    _lv_event_push(&e);

    /*Send the event*/
    lv_res_t res = event_send_core(&e);  <----- CALLED FROM HERE

    /*Remove this element from the list*/
    _lv_event_pop(&e);

    return res;
}

Here is the data contained in the local variables in the function where the error occurred


- e	0x00000017e5bee968 {current_target=0x000001d8b4d93490 original_target=0x000001d8b4d93490 code=LV_EVENT_VALUE_CHANGED (0x0000001c) ...}	_lv_event_t *
	current_target	0x000001d8b4d93490	void *
	original_target	0x000001d8b4d93490	void *
	code	LV_EVENT_VALUE_CHANGED (0x0000001c)	lv_event_code_t
	user_data	0x0000000000000000	void *
	param	0x0000000000000000	void *
    - prev	0x00000017e5beec08 {current_target=0x000001d8b4d93490 original_target=0x000001d8b4d93490 code=LV_EVENT_PRESSING (0x00000002) ...}	_lv_event_t *
		current_target	0x000001d8b4d93490	void *
		original_target	0x000001d8b4d93490	void *
	    code	LV_EVENT_PRESSING (0x00000002)	lv_event_code_t
	    user_data	0x0000000000000000	void *
	    param	0x000001d8b456dda0	void *
        prev	0x0000000000000000 <NULL>	_lv_event_t *
		deleted	0x00 '\0'	unsigned char
	    stop_processing	0x00 '\0'	unsigned char
		stop_bubbling	0x00 '\0'	unsigned char
	    deleted	0x00 '\0'	unsigned char
		stop_processing	0x00 '\0'	unsigned char
	    stop_bubbling	0x00 '\0'	unsigned char

filter	LV_EVENT_VALUE_CHANGED (0x0000001c)	lv_event_code_t
i	0x00000000	unsigned int
is_preprocessed	false	bool

- list	0x000001d8b4dbae08 {dsc=0x000001d8b4da20f0 {cb=0x000001d8b7e00fc0 user_data=0x0000000000000000 filter=...} ...}	lv_event_list_t *
    - dsc	0x000001d8b4da20f0 {cb=0x000001d8b7e00fc0 user_data=0x0000000000000000 filter=0x0000001c }	lv_event_dsc_t *
        cb	0x000001d8b7e00fc0	void(*)(_lv_event_t *)
		user_data	0x0000000000000000	void *
		filter	0x0000001c	unsigned int
	cnt	0x00000001	unsigned int
	preprocess	false	bool

and finally the exact error

Exception thrown at 0x000001D8B7E00FC0: 0xC0000005: Access violation writing location 0x00007FFBC96C4920.

This one has me baffled, I am not sure what is causing it.

The latest development version of the Python binding can be gotten from here.

https://github.com/kdschlosser/lv_cpython/tree/develop

This error occurs when running the slider_1 example. Make sure if you already have LVGL installed in Python to remove it before installing the development version. You can compile a debugging version if you use the following command

python -m setup.py build -g

Locate the built components under the build directory. To run the example in it’s current location you will need to copy the lvgl folder from the build directory into the root of the cloned repo overwriting any files and folders if it asks.

Any insight will be really helpful…

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21 (19 by maintainers)

Most upvoted comments

``c #define LV_USE_STDLIB_MALLOC LV_STDLIB_CLIB #define LV_USE_STDLIB_STRING LV_STDLIB_CLIB #define LV_USE_STDLIB_SPRINTF LV_STDLIB_CLIB


```c
#define LV_USE_ASSERT_NULL          1   /*Check if the parameter is NULL. (Very fast, recommended)*/
#define LV_USE_ASSERT_MALLOC        1   /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/
#define LV_USE_ASSERT_STYLE         0   /*Check if the styles are properly initialized. (Very fast, recommended)*/
#define LV_USE_ASSERT_MEM_INTEGRITY 0   /*Check the integrity of `lv_mem` after critical operations. (Slow)*/
#define LV_USE_ASSERT_OBJ           0   /*Check the object's type and existence (e.g. not deleted). (Slow)*/

The MALLOC is already enabled. I will do the rest and enable logging. and see what comes of it.