giuspen / cherrytree

cherrytree
https://www.giuspen.net/cherrytree/
Other
3.4k stars 461 forks source link

../../../gtk/gtktextbtree.c:4048: byte index off the end of the line #2580

Open EeyoreTheDonkee opened 1 week ago

EeyoreTheDonkee commented 1 week ago

Version, Operating system State the Version and the Operating System/Desktop. Try the latest available version before reporting an issue. 1.1.2+sfsg-1 (oracular) Ubuntu 24.10/LXQT-Openbox, 1.2.0 (AppImage) Ubuntu 24.10/LXQT-Openbox Describe the bug Clicked on an image and mouse/keyboard froze, temperature of cpu increased by 20 degrees C to 59 or so, I could not kill cherrytree from the console. I had to sign on from another system remotely and kill it. Then the error messages appeared:

Gtk-WARNING : 10:54:49.663: ../../../gtk/gtktextbtree.c:4048: byte index off the end of the line Gtk-ERROR : 10:54:49.663: Byte index 1 is off the end of the line Trace/breakpoint trap (core dumped)

Both versions behaved the same way.

To Reproduce

Open the attached db, click on the Image with the pinout diagrams of black and blue usb 3 connectors, cherrytree freezes on my system.

Unfortunately I can not give you my full database. The test database has approximately the same problem but, only cherrytree freezes, not the mouse and keyboard. Perhaps this error causes worse behavior as the database increases in size? My full db is 22 MB whereas the test db is 4.5 MB. My guess is, if you can reproduce the freeze and debug it, then the larger db will behave properly also.

CT_Freeze_100824.zip

giuspen commented 1 week ago

Thanks for submitting the issue and a test document. I just tried on my 24.04 Cinnamon desktop but didn't reproduce the freeze. I will try a virtual machine with 24.10 LxQt abd get back with the result.

EeyoreTheDonkee commented 1 week ago

Note that I'm running Lubuntu. Anyway, it is kind of a strange error. The only thing that comes to my mind, on the face of it, is that when I click on the image the app is trying to vector off and do something but, the link is a bad reference or something like that. I really don't want to dig in to the application as it must be quite complex. It has worked for many years for me and I'm not going to trash it because of this. If you can't reproduce it, perhaps the issue will just go away (after some updates, OS or whatever..) or maybe I can clean the db or mitigate the issue somehow.. Thanks in any case.

EeyoreTheDonkee commented 1 week ago

I installed the flatpak version 1.2 on a live debian trixie persistent stick and it runs fine. So, I guess it's specific to the lubuntu build @@. Ok, my problem I guess (I know there's this push to Wayland going on and it's just not ready). Well, Thank you for the post.

giuspen commented 1 week ago

I tried Lubuntu 24.10 on a VirtualBox VM, unfortunately still cannot see the crash. How much RAM do you have in your PC? image

EeyoreTheDonkee commented 1 week ago

I have 64G main and 8G swap. I'll try building it from source code and see if that makes a difference and of course this is preliminary to putting it under the debugger. Well, there are so many variables these days. Is the vm you are running a container or an emulator?

EeyoreTheDonkee commented 1 week ago

So, I was able to build it from code on the lubuntu build and run it under gdb. I had to hit Control-C after clicking on the image

gdb ./build/cherrytree GNU gdb (Ubuntu 15.1-1ubuntu2) 15.1 Copyright (C) 2024 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.

For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./build/cherrytree... (gdb) run Starting program: /home/user/apps/cherrytree-master/build/cherrytree

This GDB supports auto-downloading debuginfo from the following URLs: https://debuginfod.ubuntu.com Enable debuginfod for this session? (y or [n]) n Debuginfod has been disabled. To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff1a006c0 (LWP 637797)] [New Thread 0x7ffff10006c0 (LWP 637798)] [New Thread 0x7fffebe006c0 (LWP 637799)] [2024-10-10 20:02:50.140] [che] [debug] /home/user/.config/cherrytree/config.cfg parsed [New Thread 0x7fffeb4006c0 (LWP 637800)] [New Thread 0x7fffea4006c0 (LWP 637801)] [New Thread 0x7fffe9a006c0 (LWP 637802)] [New Thread 0x7fffe90006c0 (LWP 637803)] [Thread 0x7fffea4006c0 (LWP 637801) exited] [New Thread 0x7fffea4006c0 (LWP 637804)] [Thread 0x7fffe90006c0 (LWP 637803) exited] [2024-10-10 20:02:50.349] [che] [debug] Node 193 > USB1, USB2, Card Reader issue (solution) [Thread 0x7fffe9a006c0 (LWP 637802) exited] ^C Thread 1 "cherrytree" received signal SIGINT, Interrupt. tcache_put (chunk=0x555556b2d1a0, tc_idx=1) at ./malloc/malloc.c:3167

EeyoreTheDonkee commented 1 week ago

Well, the GUI doesn't respond after clicking on the image, but, it doesn't hang the desktop. So, I can kill it from the console. This is an improvement.

EeyoreTheDonkee commented 1 week ago

I guess virtualbox is sort of less than an emulator but more than a container.. ok, interesting

EeyoreTheDonkee commented 6 days ago

I am guessing that the code in question is CtActions::link_clicked? Is this correct?

I read a discussion about the speed of client vs server "when the client is faster than the server, blocking may halt completely the processing of the response content because the event handler does not return e.g.the client has overrun the event queue" - the solution in this case was to switch from a simple streaming model to a listener model designed to control the flow.

giuspen commented 6 days ago

But the image in your test document doesn't have any hyperlink defined, so the link clicked doesn't get called. I wonder if maybe could be some particular settings that you use... Maybe you have some settings that allow the problem to happen. Could you File--Prefereces--Export preferences and attach or send me?

EeyoreTheDonkee commented 6 days ago

yes, ok, attached.. CT_Freeze_config_101224.zip

EeyoreTheDonkee commented 6 days ago

So, if the link content reached the content test and was not a leak or a problem it would probably fall into the error clause wouldn't it? But, it isn't behaving that way.. It's just hanging and behaving like an I/O block.

giuspen commented 3 days ago

Thanks for attaching your config, I imported it, but nothing changed unfortunately. I can click on the image without hanging. There is no link content, the link is empty, if you right click and select "Edit Link..." it's empty. If want to try and debug yourself, look at src/ct/ct_image.cc:

bool CtImagePng::_on_button_press_event(GdkEventButton* event)
{
    _pCtMainWin->get_ct_actions()->curr_image_anchor = this;
    _pCtMainWin->get_ct_actions()->object_set_selection(this);
    if (event->button == 1 || event->button == 2) {
        if (event->type == GDK_2BUTTON_PRESS)
            _pCtMainWin->get_ct_actions()->image_edit();
        else if(!_link.empty())
            _pCtMainWin->get_ct_actions()->link_clicked(_link, event->button == 2);
    }
    else if (event->button == 3) {
        _pCtMainWin->get_ct_menu().find_action("img_link_dismiss")->signal_set_visible.emit(!_link.empty());
        _pCtMainWin->get_ct_menu().get_popup_menu(CtMenu::POPUP_MENU_TYPE::Image)->popup(event->button, event->time);
    }
    return true; // do not propagate the event
}

and in particular

        else if(!_link.empty())
            _pCtMainWin->get_ct_actions()->link_clicked(_link, event->button == 2);