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

Clang build crashes #280

Closed
ryze312 opened this issue Mar 29, 2024 · 5 comments
Closed

Clang build crashes #280

ryze312 opened this issue Mar 29, 2024 · 5 comments

Comments

@ryze312
Copy link
Contributor

ryze312 commented Mar 29, 2024

Building with Clang works just fine, but the build crashes at startup with

(abaddon:81377): Gtk-CRITICAL **: 18:28:43.577: gtk_tree_model_sort_get_value: assertion 'VALID_ITER (iter, tree_model_sort)' failed

Running with debugger reveals that this occurs in ChannelListTree::SelectionFunc when comparing type

bool ChannelListTree::SelectionFunc(const Glib::RefPtr<Gtk::TreeModel> &model, const Gtk::TreeModel::Path &path, bool is_currently_selected) {
if (auto selection = m_view.get_selection()) {
if (auto row = selection->get_selected()) {
m_last_selected = GetViewPathFromViewIter(row);
}
}
auto type = (*model->get_iter(path))[m_columns.m_type];
return type == RenderType::TextChannel || type == RenderType::DM || type == RenderType::Thread;
}

I am not much familiar with GTK, but it seems like type returned by get_iter is in invalid state.

@ryze312
Copy link
Contributor Author

ryze312 commented Mar 29, 2024

Clang version info:

> clang --version
clang version 16.0.6
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/naz8m910ndn4s8w4wgkh8l8wxk2bcdnk-clang-16.0.6/bin

@ouwou
Copy link
Member

ouwou commented Mar 30, 2024

can you try this? idk why iter would be invalid here but the tree model shit has always given me problems. let me know if selection breaks with this and ill look at some other options

diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp
index 4816b42..35bfa2d 100644
--- a/src/components/channellist/channellisttree.cpp
+++ b/src/components/channellist/channellisttree.cpp
@@ -1158,8 +1158,11 @@ bool ChannelListTree::SelectionFunc(const Glib::RefPtr<Gtk::TreeModel> &model, c
         }
     }
 
-    auto type = (*model->get_iter(path))[m_columns.m_type];
-    return type == RenderType::TextChannel || type == RenderType::DM || type == RenderType::Thread;
+    if (const auto iter = model->get_iter(path)) {
+        auto type = (*iter)[m_columns.m_type];
+        return type == RenderType::TextChannel || type == RenderType::DM || type == RenderType::Thread;
+    }
+    return false;
 }
 
 void ChannelListTree::AddPrivateChannels() {

@ryze312
Copy link
Contributor Author

ryze312 commented Apr 6, 2024

That fixed it, I don't see any problems with the channel selection. iter might be invalid for some reason specifically on startup. I see that by default Abaddon selects the first channel in the list.

@edshot99
Copy link

I had the same issue on OpenBSD with Clang version 13 since Abaddon version 0.1.14
I fixed this by compiling with -O1 instead of -O2.

Seems Clang's optimizations causes problems with this specific code block.

@ouwou ouwou closed this as completed in 53ad390 Jun 25, 2024
@ouwou
Copy link
Member

ouwou commented Jun 25, 2024

forgot about this but added the fix. realistically it was probably just UB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants