Re: g_ptr_array_sort crash



On Sun, Feb 13, 2005 at 12:30:07PM +0100, Gyözö Both wrote:
this is the valgrind output (with tool memcheck):

==6098== Invalid read of size 4
==6098==    at 0x807AC54: player_compare_func (player.c:393)

...

doesn't help me a lot :-(

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'.

Well, I suppose lines 393-394 and 404 are those where it
crashes `normally', so we've gained no info.

A bug in g_ptr_array_sort() is highly improbable (it's
a tested copy of well-tested glib'c qsort()) so what remains
is to debug your code the hard way.  If the array is ok
before sort starts, something must modify it during that.
You can even print complete array after each compare or
whatever, but the problem is to find where you corrupt the
data, GLib has little to do with it.

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?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]