From c882169ca6280041e25b90016a929feb880b3e5a Mon Sep 17 00:00:00 2001 From: avoidr Date: Tue, 11 Aug 2020 23:46:48 +0200 Subject: [PATCH] utox: update to 0.17.2. --- ...en-changing-toxcore-related-settings.patch | 149 ++++++++++++++++++ srcpkgs/utox/template | 3 +- 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/utox/patches/0001-Fix-crash-when-changing-toxcore-related-settings.patch diff --git a/srcpkgs/utox/patches/0001-Fix-crash-when-changing-toxcore-related-settings.patch b/srcpkgs/utox/patches/0001-Fix-crash-when-changing-toxcore-related-settings.patch new file mode 100644 index 00000000000..833b6e29dc3 --- /dev/null +++ b/srcpkgs/utox/patches/0001-Fix-crash-when-changing-toxcore-related-settings.patch @@ -0,0 +1,149 @@ +From c034ec9fffe79d46503dbb2686fec113bea2d08b Mon Sep 17 00:00:00 2001 +From: avoidr +Date: Sat, 11 Jul 2020 05:18:22 +0200 +Subject: [PATCH] Fix crash when changing toxcore-related settings + +uTox killed toxcore without killing toxav first, which led to a crash. +Resources should be deallocated in reverse order of their allocation. + +utox_av_ctrl_thread was started only once, when uTox was started, so +when toxav was killed properly, the thread was never re-created for the +next use of Tox. utox_av_ctrl_thread is now created whenever a new +toxcore starts. + +Then, the Filter_Audio pointer had to be set to NULL after it's free'd, +otherwise it wouldn't get re-initialised, and an invalid pointer would +be passed to kill_filter_audio(), causing a crash. + +Finally, replaced magic number 0 with TOX_KILL. +Deleted a redundant `toxav_thread_msg = false`. +--- + src/av/audio.c | 1 + + src/av/utox_av.c | 7 ++----- + src/main.c | 3 --- + src/tox.c | 20 +++++++++++--------- + 4 files changed, 14 insertions(+), 17 deletions(-) + +diff --git a/src/av/audio.c b/src/av/audio.c +index 324ceb22..d4384d8b 100644 +--- a/src/av/audio.c ++++ b/src/av/audio.c +@@ -909,6 +909,7 @@ void utox_audio_thread(void *args) { + } + + utox_filter_audio_kill(f_a); ++ f_a = NULL; + + // missing some cleanup ? + alDeleteSources(1, &ringtone); +diff --git a/src/av/utox_av.c b/src/av/utox_av.c +index 90e04b36..d7adb9ce 100644 +--- a/src/av/utox_av.c ++++ b/src/av/utox_av.c +@@ -275,7 +275,6 @@ void utox_av_ctrl_thread(void *UNUSED(args)) { + } + } + } +- + toxav_thread_msg = false; + + if (av) { +@@ -286,19 +285,17 @@ void utox_av_ctrl_thread(void *UNUSED(args)) { + } + } + +- + postmessage_audio(UTOXAUDIO_KILL, 0, 0, NULL); + postmessage_video(UTOXVIDEO_KILL, 0, 0, NULL); +- + // Wait for all a/v threads to return 0 + while (utox_audio_thread_init || utox_video_thread_init) { + yieldcpu(1); + } + +- toxav_thread_msg = false; ++ toxav_kill(av); ++ + utox_av_ctrl_init = false; + +- toxav_kill(av); + LOG_NOTE("UTOXAV", "Clean thread exit!"); + return; + } +diff --git a/src/main.c b/src/main.c +index a3072edf..39218062 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -269,9 +269,6 @@ void utox_init(void) { + if (settings.curr_version != settings.last_version) { + settings.show_splash = true; + } +- +- // We likely want to start this on every system. +- thread(utox_av_ctrl_thread, NULL); + } + + void utox_raze(void) { +diff --git a/src/tox.c b/src/tox.c +index 8d93ee19..e9fe3ae8 100644 +--- a/src/tox.c ++++ b/src/tox.c +@@ -234,10 +234,8 @@ void tox_settingschanged(void) { + dropdown_list_clear(&dropdown_audio_out); + dropdown_list_clear(&dropdown_video); + +- // send the reconfig message! +- postmessage_toxcore(0, 1, 0, NULL); +- + LOG_NOTE("Toxcore", "Restarting Toxcore"); ++ postmessage_toxcore(TOX_KILL, 1, 0, NULL); // send the reconfig message! + while (!tox_thread_init) { + yieldcpu(1); + } +@@ -476,8 +474,8 @@ void toxcore_thread(void *UNUSED(args)) { + // avoid trying the creation of thousands of tox instances before user changes the settings + if (tox_thread_msg) { + TOX_MSG *msg = &tox_msg; +- // If msg->msg is 0, reconfig +- if (!msg->msg) { ++ ++ if (msg->msg == TOX_KILL) { + reconfig = (bool) msg->param1; + tox_thread_init = UTOX_TOX_THREAD_INIT_NONE; + } +@@ -513,6 +511,7 @@ void toxcore_thread(void *UNUSED(args)) { + postmessage_utox(UPDATE_TRAY, 0, 0, NULL); + postmessage_utox(PROFILE_DID_LOAD, 0, 0, NULL); + ++ thread(utox_av_ctrl_thread, NULL); + postmessage_utoxav(UTOXAV_NEW_TOX_INSTANCE, 0, 0, av); + } + +@@ -548,9 +547,9 @@ void toxcore_thread(void *UNUSED(args)) { + // If there's a message, load it, and send to the tox message thread + if (tox_thread_msg) { + TOX_MSG *msg = &tox_msg; +- // If msg->msg is 0, reconfig if needed and break from tox_do +- if (!msg->msg) { +- reconfig = msg->param1; ++ ++ if (msg->msg == TOX_KILL) { ++ reconfig = msg->param1; // reconfig if needed + tox_thread_msg = 0; + tox_thread_init = UTOX_TOX_THREAD_INIT_NONE; + break; +@@ -574,7 +573,10 @@ void toxcore_thread(void *UNUSED(args)) { + write_save(tox); + edit_setstr(&edit_profile_password, (char *)"", 0); + +- // Stop toxcore. ++ postmessage_utoxav(UTOXAV_KILL, 0, 0, NULL); ++ while (utox_av_ctrl_init) { ++ yieldcpu(1); ++ } + LOG_TRACE("Toxcore", "tox thread ending"); + tox_kill(tox); + } +-- +2.26.2 + diff --git a/srcpkgs/utox/template b/srcpkgs/utox/template index 755c3203291..20f7f8c209d 100644 --- a/srcpkgs/utox/template +++ b/srcpkgs/utox/template @@ -1,7 +1,7 @@ # Template file for 'utox' pkgname=utox version=0.17.2 -revision=1 +revision=2 wrksrc=uTox build_style=cmake configure_args="-DENABLE_ASAN=OFF" @@ -15,6 +15,7 @@ license="MIT" homepage="https://github.com/uTox/uTox/" distfiles="https://github.com/uTox/uTox/releases/download/v${version}/uTox-${version}-full.tar.gz" checksum=8437827b899e4e358adaf0641680c214f4b6dfb52af6534f261d747a905f08b6 +patch_args="-Np1" nocross=yes post_install() {