Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of g_error in source code causes core dumps #221

Closed
van-de-bugger opened this issue Apr 14, 2023 · 4 comments · Fixed by #222
Closed

Usage of g_error in source code causes core dumps #221

van-de-bugger opened this issue Apr 14, 2023 · 4 comments · Fixed by #222
Labels

Comments

@van-de-bugger
Copy link

transmission-daemon-4.0.2-1.fc37.x86_64
transmission-remote-gtk-1.5.1-2.fc37.x86_64

Prerequisites:

  1. Transmission daemon is up and running, and have some active torrents (probably, completed).
  2. Transmission daemon is running using "transmission" user account.
  3. Files in /var/lib/transmission/.config/transmission-daemon/torrents belongs to "transmission" user and not accessible by other users.

Looks like it is standard linux layout.

Steps to reproduce the crash:

  1. Run transmission-remote-gtk (I suppose the user does not use "transmission" account).
  2. Press Ctrl+O, "Add a Torrent" dialog is shown.
  3. Navigate to /var/lib/transmission/.config/transmission-daemon/torrents and select any file, press "Add" button.

Voilà. transmission-remote-gtk crashed. In the terminal:

$ transmission-remote-gtk 
** (transmission-remote-gtk:15132): ERROR **: 01:35:23.063: Failed to open file “/var/lib/transmission/.config/transmission-daemon/torrents/0abc88b24de1a941754bff6f04d8fe8661f4dbe5.torrent”: open() failed: Permission denied
Trace/breakpoint trap (core dumped)

It is not a big problem, but transmission-remote-gtk should not crash if it can't open a torrent file anyway.

@van-de-bugger van-de-bugger changed the title transmission-remote-gtk crashes if can't open torrent file. transmission-remote-gtk crashes if it can't open torrent file. Apr 14, 2023
@LaserEyess LaserEyess added the bug label Apr 14, 2023
@LaserEyess
Copy link
Member

Can you get a backtrace for this?

@van-de-bugger
Copy link
Author

            Stack trace of thread 15766:
            #0  0x00007f5a69e53757 g_log_structured_array (libglib-2.0.so.0 + 0x5d757)
            #1  0x00007f5a69e53a22 g_log_default_handler (libglib-2.0.so.0 + 0x5da22)
            #2  0x00007f5a69e54e42 g_logv (libglib-2.0.so.0 + 0x5ee42)
            #3  0x00007f5a69e550f3 g_log (libglib-2.0.so.0 + 0x5f0f3)
            #4  0x00005575682f7eed trg_torrent_add_dialog_set_filenames (transmission-remote-gtk + 0x30eed)
            #5  0x00005575682fe20b trg_torrent_add_dialog_constructor (transmission-remote-gtk + 0x3720b)
            #6  0x00007f5a69f5aa14 g_object_new_with_custom_constructor (libgobject-2.0.so.0 + 0x23a14)
            #7  0x00007f5a69f5cdc3 g_object_new_valist (libgobject-2.0.so.0 + 0x25dc3)
            #8  0x00007f5a69f5d41d g_object_new (libgobject-2.0.so.0 + 0x2641d)
            #9  0x00005575682e223f add_cb (transmission-remote-gtk + 0x1b23f)
            #10 0x00007f5a69f4b060 g_closure_invoke (libgobject-2.0.so.0 + 0x14060)
            #11 0x00007f5a69f77f66 signal_emit_unlocked_R.isra.0 (libgobject-2.0.so.0 + 0x40f66)
            #12 0x00007f5a69f684da g_signal_emit_valist (libgobject-2.0.so.0 + 0x314da)
            #13 0x00007f5a69f686f3 g_signal_emit (libgobject-2.0.so.0 + 0x316f3)
            #14 0x00007f5a6a56e5d0 closure_accel_activate (libgtk-3.so.0 + 0x36e5d0)
            #15 0x00007f5a69f4b060 g_closure_invoke (libgobject-2.0.so.0 + 0x14060)
            #16 0x00007f5a69f77f66 signal_emit_unlocked_R.isra.0 (libgobject-2.0.so.0 + 0x40f66)
            #17 0x00007f5a69f67ed6 g_signal_emit_valist (libgobject-2.0.so.0 + 0x30ed6)
            #18 0x00007f5a69f686f3 g_signal_emit (libgobject-2.0.so.0 + 0x316f3)
            #19 0x00007f5a6a2a92cc gtk_accel_group_activate (libgtk-3.so.0 + 0xa92cc)
            #20 0x00007f5a6a2aec9d gtk_accel_groups_activate (libgtk-3.so.0 + 0xaec9d)
            #21 0x00007f5a6a592a66 gtk_window_activate_key (libgtk-3.so.0 + 0x392a66)
            #22 0x00007f5a6a59309c gtk_window_key_press_event.lto_priv.0 (libgtk-3.so.0 + 0x39309c)
            #23 0x00007f5a6a299c57 _gtk_marshal_BOOLEAN__BOXED (libgtk-3.so.0 + 0x99c57)
            #24 0x00007f5a69f4b060 g_closure_invoke (libgobject-2.0.so.0 + 0x14060)
            #25 0x00007f5a69f78095 signal_emit_unlocked_R.isra.0 (libgobject-2.0.so.0 + 0x41095)
            #26 0x00007f5a69f67ed6 g_signal_emit_valist (libgobject-2.0.so.0 + 0x30ed6)
            #27 0x00007f5a69f686f3 g_signal_emit (libgobject-2.0.so.0 + 0x316f3)
            #28 0x00007f5a6a57b074 gtk_widget_event_internal.part.0.lto_priv.0 (libgtk-3.so.0 + 0x37b074)
            #29 0x00007f5a6a40c65f propagate_event.lto_priv.0 (libgtk-3.so.0 + 0x20c65f)
            #30 0x00007f5a6a40d321 gtk_main_do_event (libgtk-3.so.0 + 0x20d321)
            #31 0x00007f5a6992b703 _gdk_event_emit (libgdk-3.so.0 + 0x42703)
            #32 0x00007f5a6997e846 gdk_event_source_dispatch.lto_priv.1 (libgdk-3.so.0 + 0x95846)
            #33 0x00007f5a69e4cc7f g_main_context_dispatch (libglib-2.0.so.0 + 0x56c7f)
            #34 0x00007f5a69ea3118 g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xad118)
            #35 0x00007f5a69e49f00 g_main_context_iteration (libglib-2.0.so.0 + 0x53f00)
            #36 0x00007f5a6a075f7d g_application_run (libgio-2.0.so.0 + 0xdef7d)
            #37 0x00005575682d807e main (transmission-remote-gtk + 0x1107e)
            #38 0x00007f5a69a18510 __libc_start_call_main (libc.so.6 + 0x27510)
            #39 0x00007f5a69a185c9 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x275c9)
            #40 0x00005575682d8185 _start (transmission-remote-gtk + 0x11185)
            
            Stack trace of thread 15770:
            #0  0x00007f5a69af021f __poll (libc.so.6 + 0xff21f)
            #1  0x00007f5a69ea308d g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xad08d)
            #2  0x00007f5a69e4c24f g_main_loop_run (libglib-2.0.so.0 + 0x5624f)
            #3  0x00007f5a6a0a7eca gdbus_shared_thread_func.lto_priv.0 (libgio-2.0.so.0 + 0x110eca)
            #4  0x00007f5a69e76982 g_thread_proxy (libglib-2.0.so.0 + 0x80982)
            #5  0x00007f5a69a7c12d start_thread (libc.so.6 + 0x8b12d)
            #6  0x00007f5a69afdbc0 __clone3 (libc.so.6 + 0x10cbc0)
            
            Stack trace of thread 15774:
            #0  0x00007f5a69af592d syscall (libc.so.6 + 0x10492d)
            #1  0x00007f5a69e9e793 g_cond_wait (libglib-2.0.so.0 + 0xa8793)
            #2  0x00007f5a69e1c47b g_async_queue_pop_intern_unlocked (libglib-2.0.so.0 + 0x2647b)
            #3  0x00007f5a69e7b9c1 g_thread_pool_thread_proxy.lto_priv.0 (libglib-2.0.so.0 + 0x859c1)
            #4  0x00007f5a69e76982 g_thread_proxy (libglib-2.0.so.0 + 0x80982)
            #5  0x00007f5a69a7c12d start_thread (libc.so.6 + 0x8b12d)
            #6  0x00007f5a69afdbc0 __clone3 (libc.so.6 + 0x10cbc0)
            
            Stack trace of thread 15776:
            #0  0x00007f5a69af592d syscall (libc.so.6 + 0x10492d)
            #1  0x00007f5a69e9e793 g_cond_wait (libglib-2.0.so.0 + 0xa8793)
            #2  0x00007f5a69e1c47b g_async_queue_pop_intern_unlocked (libglib-2.0.so.0 + 0x2647b)
            #3  0x00007f5a69e7b9c1 g_thread_pool_thread_proxy.lto_priv.0 (libglib-2.0.so.0 + 0x859c1)
            #4  0x00007f5a69e76982 g_thread_proxy (libglib-2.0.so.0 + 0x80982)
            #5  0x00007f5a69a7c12d start_thread (libc.so.6 + 0x8b12d)
            #6  0x00007f5a69afdbc0 __clone3 (libc.so.6 + 0x10cbc0)
            
            Stack trace of thread 15769:
            #0  0x00007f5a69af021f __poll (libc.so.6 + 0xff21f)
            #1  0x00007f5a69ea308d g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xad08d)
            #2  0x00007f5a69e49f00 g_main_context_iteration (libglib-2.0.so.0 + 0x53f00)
            #3  0x00007f5a69e4bb91 glib_worker_main (libglib-2.0.so.0 + 0x55b91)
            #4  0x00007f5a69e76982 g_thread_proxy (libglib-2.0.so.0 + 0x80982)
            #5  0x00007f5a69a7c12d start_thread (libc.so.6 + 0x8b12d)
            #6  0x00007f5a69afdbc0 __clone3 (libc.so.6 + 0x10cbc0)
            
            Stack trace of thread 15888:
            #0  0x00007f5a69af021f __poll (libc.so.6 + 0xff21f)
            #1  0x00007f5a69ea308d g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xad08d)
            #2  0x00007f5a69e49f00 g_main_context_iteration (libglib-2.0.so.0 + 0x53f00)
            #3  0x00007f5a542f038d dconf_gdbus_worker_thread (libdconfsettings.so + 0x738d)
            #4  0x00007f5a69e76982 g_thread_proxy (libglib-2.0.so.0 + 0x80982)
            #5  0x00007f5a69a7c12d start_thread (libc.so.6 + 0x8b12d)
            #6  0x00007f5a69afdbc0 __clone3 (libc.so.6 + 0x10cbc0)
            
            Stack trace of thread 15775:
            #0  0x00007f5a69af592d syscall (libc.so.6 + 0x10492d)
            #1  0x00007f5a69e9e793 g_cond_wait (libglib-2.0.so.0 + 0xa8793)
            #2  0x00007f5a69e1c47b g_async_queue_pop_intern_unlocked (libglib-2.0.so.0 + 0x2647b)
            #3  0x00007f5a69e7b9c1 g_thread_pool_thread_proxy.lto_priv.0 (libglib-2.0.so.0 + 0x859c1)
            #4  0x00007f5a69e76982 g_thread_proxy (libglib-2.0.so.0 + 0x80982)
            #5  0x00007f5a69a7c12d start_thread (libc.so.6 + 0x8b12d)
            #6  0x00007f5a69afdbc0 __clone3 (libc.so.6 + 0x10cbc0)
            
            Stack trace of thread 15782:
            #0  0x00007f5a69af592d syscall (libc.so.6 + 0x10492d)
            #1  0x00007f5a69e9ede0 g_cond_wait_until (libglib-2.0.so.0 + 0xa8de0)
            #2  0x00007f5a69e1c451 g_async_queue_pop_intern_unlocked (libglib-2.0.so.0 + 0x26451)
            #3  0x00007f5a69e7bb0a g_thread_pool_thread_proxy.lto_priv.0 (libglib-2.0.so.0 + 0x85b0a)
            #4  0x00007f5a69e76982 g_thread_proxy (libglib-2.0.so.0 + 0x80982)
            #5  0x00007f5a69a7c12d start_thread (libc.so.6 + 0x8b12d)
            #6  0x00007f5a69afdbc0 __clone3 (libc.so.6 + 0x10cbc0)
            ELF object binary architecture: AMD x86-64

Is this ok?

@LaserEyess
Copy link
Member

LaserEyess commented Apr 15, 2023

Ok, I can reproduce this.

sudo touch /tmp/root.torrent
sudo chmod 600 /tmp/root.torrent

Try to open root.torrent with trg. I'll take a look today.

Well...

Error messages are always fatal, resulting in a call to G_BREAKPOINT() to terminate the application. This function will result in a core dump; don’t use it for errors you expect. Using this function indicates a bug in your program, i.e. an assertion failure.

ok then, gotta drop that.

@LaserEyess
Copy link
Member

LaserEyess commented Apr 15, 2023

grep -nE 'g_error\(' src/*.c 
src/requests.c:273:            g_error("unable to base64 encode file \"%s\".", target);
src/trg-file-parser.c:192:        g_error("%s", error->message);
src/trg-prefs.c:422:        g_error("Problem creating parent directory (permissions?) for: %s\n", priv->file);
src/trg-prefs.c:448:        g_error("Problem writing configuration file (permissions?) to: %s", priv->file);
src/util.c:190:        g_error("%s", error->message);

I think a proper solution is doing something like #170, but for all of these. The trouble is I am not familiar with libgd (or honestly a lot of deeper GTK stuff) and I would have to experiment a lot. Really this code base needs a lot of refactoring.

@LaserEyess LaserEyess changed the title transmission-remote-gtk crashes if it can't open torrent file. Usage of g_error in source code causes core dumps Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants