Re: g_ptr_array_sort crash
- From: Tim Müller <zen18864 zen co uk>
- To: gtk-app-devel-list gnome org
- Cc: Gyözö Both <gyboth bygfoot com>
- Subject: Re: g_ptr_array_sort crash
- Date: Sun, 13 Feb 2005 12:23:32 +0000
On Sunday 13 February 2005 08:06, Gyözö Both wrote:
i'm sorting a pointer array and every once in a while i get a segfault.
i'm checking the pointers before sorting with
g_ptr_array_sort_with_data, and they are fine. the data i pass, an
integer (with GINT_TO_POINTER) is also all right.
the crash happens in the compare function, which looks like this:
(snip)
i print out the two pointers pl1 and pl2, and mostly they are fine, but
sometimes one of them looks weird (0x049) and is obviously invalid, so
i get a segfault when the function tries to access the struct members.
as i said, the pointers in the array are all valid and ok before i call
g_ptr_array_sort.
i don't have a clue what the problem could be :-( hope you have ideas.
This might be happening because your compare function is inconsistent, e.g.
when
player_compare_func (foo, bar, x) returns a value < 0
and
player_compare_func (bar, foo, x) returns 0 (instead of a value > 0)
or
player_compare_func (bar, bar, x) returns a value != 0 (instead of 0)
or something similar.
Cheers
-Tim
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]