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

/plugin install does not work with redirect links + occasional crash #1901

Closed
H3rnand3zzz opened this issue Oct 19, 2023 · 2 comments · Fixed by #1919 or #1922
Closed

/plugin install does not work with redirect links + occasional crash #1901

H3rnand3zzz opened this issue Oct 19, 2023 · 2 comments · Fixed by #1919 or #1922
Assignees
Labels
Milestone

Comments

@H3rnand3zzz
Copy link
Contributor

Expected Behavior

On /plugins install <redirect_link>, follow the redirect, download the plugin.

Current Behavior

On /plugins install <redirect_link>, it just "downloads" an empty file and loads it without an error. Also sometimes it leads to a crash.

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f44ce6562fe in __GI___libc_free (mem=0x7f435c4b070a)
    at malloc.c:3368
Downloading source file /usr/src/debug/glibc/glibc/malloc/malloc.c
3368      if (chunk_is_mmapped (p))                       /* release mmapped memory. */
[Current thread is 1 (Thread 0x7f44bb72c6c0 (LWP 99432))]
(gdb) where
#0  0x00007f44ce6562fe in __GI___libc_free (mem=0x7f435c4b070a)
    at malloc.c:3368
#1  0x00007f44ceb69746 in g_strfreev () at /usr/lib/libglib-2.0.so.0
#2  0x000055afc91a445d in auto_free_gcharv (args=<optimized out>)
    at src/common.c:117
#3  0x000055afc9217875 in conf_string_list_add
    (keyfile=<optimized out>, group=group@entry=0x55afc92480ec "plugins", key=key@entry=0x55afc9248aad "load", item=item@entry=0x7f44a8018750 "syscmd.py")
    at src/config/conflists.c:46
#4  0x000055afc921e441 in prefs_add_plugin
    (name=name@entry=0x7f44a8018750 "syscmd.py")
    at src/config/preferences.c:888
#5  0x000055afc9224b42 in plugins_load
    (name=name@entry=0x7f44a8018750 "syscmd.py", error_message=error_message@entry=0x7f44a80010f0) at src/plugins/plugins.c:262
#6  0x000055afc9224d2b in plugins_install
    (plugin_name=0x7f44a8018750 "syscmd.py", filename=0x7f44a8000b70 "/{user_home}/.local/share/profanity/downloads/syscmd.py", error_message=error_message@entry=0x7f44a80010f0) at src/plugins/plugins.c:203
#7  0x000055afc9215ba7 in plugin_download_install (userdata=<optimized out>)
    at src/tools/plugin_download.c:76
#8  0x00007f44ce6459eb in start_thread (arg=<optimized out>)
    at pthread_create.c:444
#9  0x00007f44ce6c97cc in clone3 ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Possible Solution

Null-check for file, following the redirects, fix the crash as well.

Steps to Reproduce (for bugs)

  1. Use /plugins install https://github.com/profanity-im/profanity-plugins/raw/master/stable/syscmd.py

Context

Self-explanatory

Environment

Master branch, other environment does not matter :)

@jubalh jubalh added the bug label Oct 19, 2023
@jubalh jubalh changed the title [bug] /plugin install does not work with redirect links + occasional crash /plugin install does not work with redirect links + occasional crash Oct 19, 2023
@jubalh jubalh added this to the next milestone Oct 19, 2023
@jubalh
Copy link
Member

jubalh commented Oct 20, 2023

I believe curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); should be enough to follow redirects.

But the /plugins install https://github.com/profanity-im/profanity-plugins/raw/master/stable/syscmd.py fails because it is downloading the file as ~/.local/share/profanity/plugins/syscmd.py.0 and then tries to start it as syscmd.py. And then it won't be in the hash table.

AFAIK this code is from you. Maybe you still remember what is the idea behind this? I can continue to look at it the next days.

And I got also the following, but I think that's two different issues:

0x00007ffff6ca149e in __GI___libc_free (mem=mem@entry=0x7ff823e9bcc2)
    at malloc.c:3368
Downloading source file /usr/src/debug/glibc-2.38/malloc/malloc.c
3368      if (chunk_is_mmapped (p))                       /* release mmapped memory. */
(gdb) bt
#0  0x00007ffff6ca149e in __GI___libc_free (mem=mem@entry=0x7ff823e9bcc2)
    at malloc.c:3368
#1  0x00007ffff731aa09 in g_free (mem=0x7ff823e9bcc2) at ../glib/gmem.c:238
#2  0x00007ffff7336c35 in g_strfreev (str_array=<optimized out>)
    at ../glib/gstrfuncs.c:2590
#3  g_strfreev (str_array=0x7fffdc112f80) at ../glib/gstrfuncs.c:2583
#4  0x0000000000431380 in auto_free_gcharv (args=0x7fffef7fdbd8)
    at src/common.c:117
#5  0x00000000004d0e3e in conf_string_list_add
    (keyfile=0x5d95c0, group=0x58a04f "plugins", key=0x58a22c "load", item=0x7fffdc14a800 "syscmd.py") at src/config/conflists.c:46
#6  0x00000000004d749a in prefs_add_plugin (name=0x7fffdc14a800 "syscmd.py")
    at src/config/preferences.c:888
#7  0x00000000004e258f in plugins_load
    (name=0x7fffdc14a800 "syscmd.py", error_message=0x7fffdc14a350)
    at src/plugins/plugins.c:262
#8  0x00000000004e21e8 in plugins_install
    (plugin_name=0x7fffdc14a800 "syscmd.py", filename=0x7fffdc000b70 "/home/michael/.local/share/profanity/downloads/syscmd.py.2", error_message=0x7fffdc14a350) at src/plugins/plugins.c:203
#9  0x00000000004ce023 in plugin_download_install (userdata=0xfe8200)
    at src/tools/plugin_download.c:76
#10 0x00007ffff6c8ff44 in start_thread (arg=<optimized out>)

Might be a problem with 865a056 ?

H3rnand3zzz added a commit to H3rnand3zzz/profanity that referenced this issue Nov 10, 2023
Double free was introduced earlier in a cleanup commit
865a056

It was reported earlier by me and then by @jubalh profanity-im#1901
H3rnand3zzz added a commit to H3rnand3zzz/profanity that referenced this issue Nov 10, 2023
H3rnand3zzz added a commit to H3rnand3zzz/profanity that referenced this issue Nov 10, 2023
Empty file is not a normal condition for file downloading,
thus user has to be notifed.

Related to profanity-im#1901
@H3rnand3zzz
Copy link
Contributor Author

Once both PRs are merged, issue can be closed.

H3rnand3zzz added a commit to H3rnand3zzz/profanity that referenced this issue Nov 10, 2023
H3rnand3zzz added a commit to H3rnand3zzz/profanity that referenced this issue Nov 10, 2023
Empty file is not a normal condition for file downloading,
thus user has to be notifed.

Related to profanity-im#1901
H3rnand3zzz added a commit to H3rnand3zzz/profanity that referenced this issue Nov 11, 2023
H3rnand3zzz added a commit to H3rnand3zzz/profanity that referenced this issue Nov 11, 2023
Empty file is not a normal condition for file downloading,
thus user has to be notifed.

Related to profanity-im#1901
H3rnand3zzz added a commit to H3rnand3zzz/profanity that referenced this issue Nov 11, 2023
Double free was introduced earlier in a cleanup commit
865a056

It was reported earlier by me and then by @jubalh profanity-im#1901
H3rnand3zzz added a commit to H3rnand3zzz/profanity that referenced this issue Nov 13, 2023
Double free was introduced earlier in a cleanup commit
865a056

It was reported earlier by me and then by @jubalh profanity-im#1901
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants