Re: g_ptr_array_sort crash
- From: Gyözö Both <gyboth bygfoot com>
- To: "David Necas (Yeti)" <yeti physics muni cz>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: g_ptr_array_sort crash
- Date: Sun, 13 Feb 2005 12:30:07 +0100
this is the valgrind output (with tool memcheck):
==6098== Invalid read of size 4
==6098== at 0x807AC54: player_compare_func (player.c:393)
==6098== by 0x1BD7504D: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0 .400.6)
==6098== by 0x1BD50B40: g_ptr_array_sort_with_data (in
/opt/gnome/lib/libglib -2.0.so.0.400.6)
==6098== by 0x805BF3A: game_get_penalty_taker (game.c:200)
==6098== Address 0x9C61DD78 is not stack'd, malloc'd or (recently)
free'd ==6098==
==6098== Process terminating with default action of signal 11 (SIGSEGV)
==6098== at 0x807AC54: player_compare_func (player.c:393)
==6098== by 0x1BD7504D: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0 .400.6)
==6098== by 0x1BD50B40: g_ptr_array_sort_with_data (in
/opt/gnome/lib/libglib -2.0.so.0.400.6)
==6098== by 0x805BF3A: game_get_penalty_taker (game.c:200)
and this with corecheck:
==6123== Process terminating with default action of signal 11 (SIGSEGV)
==6123== Access not within mapped region at address 0x881C1614
==6123== at 0x807AC54: player_compare_func (player.c:393)
==6123== by 0x3ADEF04D: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6123== by 0x3ADCAB40:
g_ptr_array_sort_with_data (in /opt/gnome/lib/libglib-2.0.so.0.400.6)
==6123== by 0x805BF3A: game_get_penalty_taker (game.c:200)
and addrcheck:
==6138== Invalid read of size 4
==6138== at 0x807AC52: player_compare_func (player.c:394)
==6138== by 0x345BAE9B: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138== by 0x34596B40:
g_ptr_array_sort_with_data (in /opt/gnome/lib/libglib-2.0.so.0.400.6)
==6138== by 0x805BF3A: game_get_penalty_taker (game.c:200) ==6138==
Address 0x34E79174 is 4 bytes before a block of size 64 alloc'd ==6138==
at 0x341492F4: malloc (in /usr/lib/valgrind/vgpreload_addrcheck.so)
==6138== by 0x34149CF7: realloc (in
/usr/lib/valgrind/vgpreload_addrcheck.so) ==6138== by 0x345B4C10:
g_realloc (in /opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138== by
0x34596E17: g_ptr_array_maybe_expand (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138==
==6138== Invalid read of size 4
==6138== at 0x807ACAA: player_compare_func (player.c:404)
==6138== by 0x345BAE9B: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138== by 0x34596B40:
g_ptr_array_sort_with_data (in /opt/gnome/lib/libglib-2.0.so.0.400.6)
==6138== by 0x805BF3A: game_get_penalty_taker (game.c:200) ==6138==
Address 0xF is not stack'd, malloc'd or (recently) free'd ==6138==
==6138== Process terminating with default action of signal 11 (SIGSEGV)
==6138== Access not within mapped region at address 0xF
==6138== at 0x807ACAA: player_compare_func (player.c:404)
==6138== by 0x345BAE9B: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138== by 0x34596B40:
g_ptr_array_sort_with_data (in /opt/gnome/lib/libglib-2.0.so.0.400.6)
==6138== by 0x805BF3A: game_get_penalty_taker (game.c:200)
doesn't help me a lot :-(
gyözö
On Sun, Feb 13, 2005 at 09:06:50AM +0100, 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.
...
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.
Try valgrind, because this looks like consequences of
a memory problem that occurs elsewhere. There are two
common problems it may not catch: overwritten stack and
wrong level of indirection (i.e., you used too much &'s
somewhere), but chances are it will find that `elsewhere'.
Yeti
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
--
I went to the race track once and bet on a horse that was so good that
it took seven others to beat him!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]