Re: Troubleshooting segfault

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

 





On 8/4/05, ibr@xxxxxxxxxxxxxxxxx <ibr@xxxxxxxxxxxxxxxxx> wrote:
Hello Jonathan,

On Thu, Aug 04, 2005 at 02:34:50PM -0500, Jonathan Hayward wrote:
> I've been developing an application, and now it crashes shortly after
> starting; it segfaults (secondary damage?) either on the first attempt to
> strncpy() from a text input, or gtk_image_new_from_pixbuf(). Both of these
> were working reliably, and I haven't touched that area of code (but double
> checked just in case).
>
> How should I go about troubleshooting a segfault early on in execution? What
> kind of problems should I be looking for?The code is at
> http://haywardfamily.org/jonathan/gtk_tms.tgz .

1. Analyse core with gdb.

2. Use valgrind to see whether you corrupt memory before the crash.

Thank you. I hadn't used valgrind; it reports my game as crashing at the same time, under the same conditions, as gdb. There were no problems reported prior to the segfault gdb had picked up.

When I used valgrind, I the segfault appeared to be coming from gtk_entry_get_text(GTK_ENTRY(GtkWidget *entry)).

entry is a module level variable that is set equal to gtk_entry_new() and nothing else. The sequence of events is:

* Program puts up a modal dialog with a text entry.
  (including creating the entry with gtk_entry_new().)
* Program enters gtk_dialog_run()
* User types something in, and clicks the button.
* Signal handler copies the text entry's data.
* Signal handler destroys the window.

I'm scratching my head at how the pointer to the entry could be corrupted between when the entry is created and when the signal handler reads the value. The pointer is corrupt; on two runs I got values of 0x0/0xFF.

If a buffer overflow had overwritten the pointer, would valgrind observe it? If valgrind doesn't report problems before the segmentation violation, does it mean that there probably isn't a memory error other than the segv?

Thank you,

With kind regards,
Baurzhan.
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list



--
++ Jonathan Hayward, jonathan.hayward@xxxxxxxxx
** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com

** If you'd like a Google Mail (gmail.com) account, please tell me!
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux