Valgrind sometimes (?) unhappy when user sends message
I'm running chatty under valgrind (see libcmatrix!18 (comment 213233))
and noticed whenever I send a (matrix) message valgrind will yell at me:
19:12:59.6501 chatty-chat-view[777037]: TRACE: chat_view_save_message_to_db():574: Saving draft to !P################C:f############o.eu
==777037== Thread 6:
==777037== Invalid read of size 1
==777037== at 0x4846782: strlen (vg_replace_strmem.c:494)
==777037== by 0x5BDE9EA: sqlite3VdbeMemSetStr (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x5BD59A6: ??? (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x1A7A4B: history_bind_text (chatty-history.c:435)
==777037== by 0x1ACE58: history_add_message (chatty-history.c:2590)
==777037== by 0x1AF68E: chatty_history_worker (chatty-history.c:3268)
==777037== by 0x4C60C0C: g_thread_proxy (gthread.c:831)
==777037== by 0x63CBB26: start_thread (pthread_create.c:435)
==777037== by 0x644DABF: clone (clone.S:100)
==777037== Address 0x23ad4b20 is 0 bytes inside a block of size 1 free'd
==777037== at 0x484317B: free (vg_replace_malloc.c:872)
==777037== by 0x1A50B3: chatty_message_set_text (chatty-message.c:536)
==777037== by 0x194677: chat_view_save_message_to_db (chatty-chat-view.c:589)
==777037== by 0x4C37119: g_timeout_dispatch (gmain.c:5007)
==777037== by 0x4C365FE: g_main_dispatch (gmain.c:3444)
==777037== by 0x4C365FE: g_main_context_dispatch (gmain.c:4162)
==777037== by 0x4C369B7: g_main_context_iterate.constprop.0 (gmain.c:4238)
==777037== by 0x4C36A4B: g_main_context_iteration (gmain.c:4303)
==777037== by 0x1D092D: cm_db_add_room_events (cm-db.c:3417)
==777037== by 0x1DFADB: room_add_event_to_db (cm-room.c:214)
==777037== by 0x1E24BD: send_cb (cm-room.c:1170)
==777037== by 0x4A4B6A8: g_task_return_now (gtask.c:1232)
==777037== by 0x4A4C202: g_task_return (gtask.c:1301)
==777037== by 0x4A4C202: g_task_return (gtask.c:1258)
==777037== Block was alloc'd at
==777037== at 0x48407B4: malloc (vg_replace_malloc.c:381)
==777037== by 0x4C3C5F8: g_malloc (gmem.c:127)
==777037== by 0x4C56B9E: g_strdup (gstrfuncs.c:363)
==777037== by 0x1A50BF: chatty_message_set_text (chatty-message.c:537)
==777037== by 0x194276: chat_view_send_message_button_clicked_cb (chatty-chat-view.c:535)
==777037== by 0x194433: chat_view_input_key_pressed_cb (chatty-chat-view.c:553)
==777037== by 0x52B9056: _gtk_marshal_BOOLEAN__BOXED (gtkmarshalers.c:83)
==777037== by 0x4B984FF: g_closure_invoke (gclosure.c:832)
==777037== by 0x4BABB35: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
==777037== by 0x4BB1EEC: g_signal_emit_valist (gsignal.c:3559)
==777037== by 0x4BB287E: g_signal_emit (gsignal.c:3606)
==777037== by 0x5263553: gtk_widget_event_internal.part.0 (gtkwidget.c:7812)
==777037==
==777037== Invalid read of size 1
==777037== at 0x484A430: memmove (vg_replace_strmem.c:1382)
==777037== by 0x5BDE901: sqlite3VdbeMemSetStr (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x5BD59A6: ??? (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x1A7A4B: history_bind_text (chatty-history.c:435)
==777037== by 0x1ACE58: history_add_message (chatty-history.c:2590)
==777037== by 0x1AF68E: chatty_history_worker (chatty-history.c:3268)
==777037== by 0x4C60C0C: g_thread_proxy (gthread.c:831)
==777037== by 0x63CBB26: start_thread (pthread_create.c:435)
==777037== by 0x644DABF: clone (clone.S:100)
==777037== Address 0x23ad4b20 is 0 bytes inside a block of size 1 free'd
==777037== at 0x484317B: free (vg_replace_malloc.c:872)
==777037== by 0x1A50B3: chatty_message_set_text (chatty-message.c:536)
==777037== by 0x194677: chat_view_save_message_to_db (chatty-chat-view.c:589)
==777037== by 0x4C37119: g_timeout_dispatch (gmain.c:5007)
==777037== by 0x4C365FE: g_main_dispatch (gmain.c:3444)
==777037== by 0x4C365FE: g_main_context_dispatch (gmain.c:4162)
==777037== by 0x4C369B7: g_main_context_iterate.constprop.0 (gmain.c:4238)
==777037== by 0x4C36A4B: g_main_context_iteration (gmain.c:4303)
==777037== by 0x1D092D: cm_db_add_room_events (cm-db.c:3417)
==777037== by 0x1DFADB: room_add_event_to_db (cm-room.c:214)
==777037== by 0x1E24BD: send_cb (cm-room.c:1170)
==777037== by 0x4A4B6A8: g_task_return_now (gtask.c:1232)
==777037== by 0x4A4C202: g_task_return (gtask.c:1301)
==777037== by 0x4A4C202: g_task_return (gtask.c:1258)
==777037== Block was alloc'd at
==777037== at 0x48407B4: malloc (vg_replace_malloc.c:381)
==777037== by 0x4C3C5F8: g_malloc (gmem.c:127)
==777037== by 0x4C56B9E: g_strdup (gstrfuncs.c:363)
==777037== by 0x1A50BF: chatty_message_set_text (chatty-message.c:537)
==777037== by 0x194276: chat_view_send_message_button_clicked_cb (chatty-chat-view.c:535)
==777037== by 0x194433: chat_view_input_key_pressed_cb (chatty-chat-view.c:553)
==777037== by 0x52B9056: _gtk_marshal_BOOLEAN__BOXED (gtkmarshalers.c:83)
==777037== by 0x4B984FF: g_closure_invoke (gclosure.c:832)
==777037== by 0x4BABB35: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
==777037== by 0x4BB1EEC: g_signal_emit_valist (gsignal.c:3559)
==777037== by 0x4BB287E: g_signal_emit (gsignal.c:3606)
==777037== by 0x5263553: gtk_widget_event_internal.part.0 (gtkwidget.c:7812)
==777037==
or
==777037== Invalid read of size 1
==777037== at 0x4846794: strlen (vg_replace_strmem.c:494)
==777037== by 0x5BDE9EA: sqlite3VdbeMemSetStr (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x5BD59A6: ??? (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x1A7A4B: history_bind_text (chatty-history.c:435)
==777037== by 0x1ACE58: history_add_message (chatty-history.c:2590)
==777037== by 0x1AF68E: chatty_history_worker (chatty-history.c:3268)
==777037== by 0x4C60C0C: g_thread_proxy (gthread.c:831)
==777037== by 0x63CBB26: start_thread (pthread_create.c:435)
==777037== by 0x644DABF: clone (clone.S:100)
==777037== Address 0x320a85c1 is 1 bytes inside a block of size 13 free'd
==777037== at 0x484317B: free (vg_replace_malloc.c:872)
==777037== by 0x1A50B3: chatty_message_set_text (chatty-message.c:536)
==777037== by 0x194276: chat_view_send_message_button_clicked_cb (chatty-chat-view.c:535)
==777037== by 0x194433: chat_view_input_key_pressed_cb (chatty-chat-view.c:553)
==777037== by 0x52B9056: _gtk_marshal_BOOLEAN__BOXED (gtkmarshalers.c:83)
==777037== by 0x4B984FF: g_closure_invoke (gclosure.c:832)
==777037== by 0x4BABB35: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
==777037== by 0x4BB1EEC: g_signal_emit_valist (gsignal.c:3559)
==777037== by 0x4BB287E: g_signal_emit (gsignal.c:3606)
==777037== by 0x5263553: gtk_widget_event_internal.part.0 (gtkwidget.c:7812)
==777037== by 0x528485A: gtk_window_propagate_key_event (gtkwindow.c:8224)
==777037== by 0x5288BCA: gtk_window_key_press_event (gtkwindow.c:8257)
==777037== Block was alloc'd at
==777037== at 0x48407B4: malloc (vg_replace_malloc.c:381)
==777037== by 0x4C3C5F8: g_malloc (gmem.c:127)
==777037== by 0x4C56B9E: g_strdup (gstrfuncs.c:363)
==777037== by 0x1A50BF: chatty_message_set_text (chatty-message.c:537)
==777037== by 0x194677: chat_view_save_message_to_db (chatty-chat-view.c:589)
==777037== by 0x4C37119: g_timeout_dispatch (gmain.c:5007)
==777037== by 0x4C365FE: g_main_dispatch (gmain.c:3444)
==777037== by 0x4C365FE: g_main_context_dispatch (gmain.c:4162)
==777037== by 0x4C369B7: g_main_context_iterate.constprop.0 (gmain.c:4238)
==777037== by 0x4C36A4B: g_main_context_iteration (gmain.c:4303)
==777037== by 0x4A7AD5C: g_application_run (gapplication.c:2571)
==777037== by 0x1410FC: main (main.c:37)
==777037==
==777037== Invalid read of size 8
==777037== at 0x484A3AE: memmove (vg_replace_strmem.c:1382)
==777037== by 0x5BDE901: sqlite3VdbeMemSetStr (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x5BD59A6: ??? (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x1A7A4B: history_bind_text (chatty-history.c:435)
==777037== by 0x1ACE58: history_add_message (chatty-history.c:2590)
==777037== by 0x1AF68E: chatty_history_worker (chatty-history.c:3268)
==777037== by 0x4C60C0C: g_thread_proxy (gthread.c:831)
==777037== by 0x63CBB26: start_thread (pthread_create.c:435)
==777037== by 0x644DABF: clone (clone.S:100)
==777037== Address 0x320a85c0 is 0 bytes inside a block of size 13 free'd
==777037== at 0x484317B: free (vg_replace_malloc.c:872)
==777037== by 0x1A50B3: chatty_message_set_text (chatty-message.c:536)
==777037== by 0x194276: chat_view_send_message_button_clicked_cb (chatty-chat-view.c:535)
==777037== by 0x194433: chat_view_input_key_pressed_cb (chatty-chat-view.c:553)
==777037== by 0x52B9056: _gtk_marshal_BOOLEAN__BOXED (gtkmarshalers.c:83)
==777037== by 0x4B984FF: g_closure_invoke (gclosure.c:832)
==777037== by 0x4BABB35: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
==777037== by 0x4BB1EEC: g_signal_emit_valist (gsignal.c:3559)
==777037== by 0x4BB287E: g_signal_emit (gsignal.c:3606)
==777037== by 0x5263553: gtk_widget_event_internal.part.0 (gtkwidget.c:7812)
==777037== by 0x528485A: gtk_window_propagate_key_event (gtkwindow.c:8224)
==777037== by 0x5288BCA: gtk_window_key_press_event (gtkwindow.c:8257)
==777037== Block was alloc'd at
==777037== at 0x48407B4: malloc (vg_replace_malloc.c:381)
==777037== by 0x4C3C5F8: g_malloc (gmem.c:127)
==777037== by 0x4C56B9E: g_strdup (gstrfuncs.c:363)
==777037== by 0x1A50BF: chatty_message_set_text (chatty-message.c:537)
==777037== by 0x194677: chat_view_save_message_to_db (chatty-chat-view.c:589)
==777037== by 0x4C37119: g_timeout_dispatch (gmain.c:5007)
==777037== by 0x4C365FE: g_main_dispatch (gmain.c:3444)
==777037== by 0x4C365FE: g_main_context_dispatch (gmain.c:4162)
==777037== by 0x4C369B7: g_main_context_iterate.constprop.0 (gmain.c:4238)
==777037== by 0x4C36A4B: g_main_context_iteration (gmain.c:4303)
==777037== by 0x4A7AD5C: g_application_run (gapplication.c:2571)
==777037== by 0x1410FC: main (main.c:37)
==777037==
==777037== Invalid read of size 2
==777037== at 0x484A400: memmove (vg_replace_strmem.c:1382)
==777037== by 0x5BDE901: sqlite3VdbeMemSetStr (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x5BD59A6: ??? (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)
==777037== by 0x1A7A4B: history_bind_text (chatty-history.c:435)
==777037== by 0x1ACE58: history_add_message (chatty-history.c:2590)
==777037== by 0x1AF68E: chatty_history_worker (chatty-history.c:3268)
==777037== by 0x4C60C0C: g_thread_proxy (gthread.c:831)
==777037== by 0x63CBB26: start_thread (pthread_create.c:435)
==777037== by 0x644DABF: clone (clone.S:100)
==777037== Address 0x320a85c8 is 8 bytes inside a block of size 13 free'd
==777037== at 0x484317B: free (vg_replace_malloc.c:872)
==777037== by 0x1A50B3: chatty_message_set_text (chatty-message.c:536)
==777037== by 0x194276: chat_view_send_message_button_clicked_cb (chatty-chat-view.c:535)
==777037== by 0x194433: chat_view_input_key_pressed_cb (chatty-chat-view.c:553)
==777037== by 0x52B9056: _gtk_marshal_BOOLEAN__BOXED (gtkmarshalers.c:83)
==777037== by 0x4B984FF: g_closure_invoke (gclosure.c:832)
==777037== by 0x4BABB35: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
==777037== by 0x4BB1EEC: g_signal_emit_valist (gsignal.c:3559)
==777037== by 0x4BB287E: g_signal_emit (gsignal.c:3606)
==777037== by 0x5263553: gtk_widget_event_internal.part.0 (gtkwidget.c:7812)
==777037== by 0x528485A: gtk_window_propagate_key_event (gtkwindow.c:8224)
==777037== by 0x5288BCA: gtk_window_key_press_event (gtkwindow.c:8257)
==777037== Block was alloc'd at
==777037== at 0x48407B4: malloc (vg_replace_malloc.c:381)
==777037== by 0x4C3C5F8: g_malloc (gmem.c:127)
==777037== by 0x4C56B9E: g_strdup (gstrfuncs.c:363)
==777037== by 0x1A50BF: chatty_message_set_text (chatty-message.c:537)
==777037== by 0x194677: chat_view_save_message_to_db (chatty-chat-view.c:589)
==777037== by 0x4C37119: g_timeout_dispatch (gmain.c:5007)
==777037== by 0x4C365FE: g_main_dispatch (gmain.c:3444)
==777037== by 0x4C365FE: g_main_context_dispatch (gmain.c:4162)
==777037== by 0x4C369B7: g_main_context_iterate.constprop.0 (gmain.c:4238)
==777037== by 0x4C36A4B: g_main_context_iteration (gmain.c:4303)
==777037== by 0x4A7AD5C: g_application_run (gapplication.c:2571)
==777037== by 0x1410FC: main (main.c:37)
Edit: This does not happen for every message sent
Edited by Evangelos Ribeiro Tzaras