unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* segfault: g_type_init() missing
@ 2011-07-24  4:32 Aaron Ecay
  2011-07-24  5:51 ` Jameson Graef Rollins
  0 siblings, 1 reply; 7+ messages in thread
From: Aaron Ecay @ 2011-07-24  4:32 UTC (permalink / raw)
  To: notmuch

Dear all,

I just pulled the last couple weeks' worth of changes and rebuilt
notmuch, only to have the new binary give a segfault on "notmuch new"
(running on OS X.6).  The error message printed was:

(process:21821): GLib-GObject-CRITICAL **: gtype.c:2708: You forgot to
call g_type_init()

And the backtrace (from gdb):

#0  0x000a18f7 in g_object_newv ()
#1  0x000160e4 in notmuch_filter_discard_uuencode_new ()
#2  0x000163f0 in _index_mime_part ()
#3  0x0001667a in _notmuch_message_index_file ()
#4  0x0001247c in notmuch_database_add_message ()
#5  0x000065a9 in add_files_recursive ()
#6  0x0000612c in add_files_recursive ()
#7  0x0000612c in add_files_recursive ()
#8  0x000071ec in notmuch_new_command ()
#9  0x00003a5a in main ()

According to the Glib docs
(http://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#g-type-init),
the g_type_init() function must be called before using any GType
stuff, which notmuch_filter_discard_uuencode_new does.  There are no
grep hits for g_type_init in the notmuch sources, though.  The code on
the error path looks pretty old, so I'm not sure why this bug hasn't
hit someone else before.  Adding a call to g_type_init() to main()
(right after g_mime_init(0)) fixes the problem.

Aaron

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: segfault: g_type_init() missing
  2011-07-24  4:32 segfault: g_type_init() missing Aaron Ecay
@ 2011-07-24  5:51 ` Jameson Graef Rollins
  2011-07-25 20:33   ` [PATCH] Add missing call to g_type_init() Aaron Ecay
  0 siblings, 1 reply; 7+ messages in thread
From: Jameson Graef Rollins @ 2011-07-24  5:51 UTC (permalink / raw)
  To: Aaron Ecay, notmuch

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]

On Sun, 24 Jul 2011 00:32:39 -0400, Aaron Ecay <aaronecay@gmail.com> wrote:
> According to the Glib docs
> (http://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#g-type-init),
> the g_type_init() function must be called before using any GType
> stuff, which notmuch_filter_discard_uuencode_new does.  There are no
> grep hits for g_type_init in the notmuch sources, though.  The code on
> the error path looks pretty old, so I'm not sure why this bug hasn't
> hit someone else before.  Adding a call to g_type_init() to main()
> (right after g_mime_init(0)) fixes the problem.

Hey, Aaron.  Since you've found a suitable fix, would you mind providing
a patch (from git send-email for instance)?  Simple bug fixes tend to
get applied fairly quickly if well formatted patches are included.
Thanks.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Add missing call to g_type_init()
  2011-07-24  5:51 ` Jameson Graef Rollins
@ 2011-07-25 20:33   ` Aaron Ecay
  2011-07-25 20:53     ` Jameson Graef Rollins
  0 siblings, 1 reply; 7+ messages in thread
From: Aaron Ecay @ 2011-07-25 20:33 UTC (permalink / raw)
  To: notmuch


Signed-off-by: Aaron Ecay <aaronecay@gmail.com>
---
 notmuch.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/notmuch.c b/notmuch.c
index 3973e35..f9d6629 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -579,6 +579,7 @@ main (int argc, char *argv[])
     local = talloc_new (NULL);
 
     g_mime_init (0);
+    g_type_init ();
 
     if (argc == 1)
 	return notmuch (local);
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add missing call to g_type_init()
  2011-07-25 20:33   ` [PATCH] Add missing call to g_type_init() Aaron Ecay
@ 2011-07-25 20:53     ` Jameson Graef Rollins
  2011-07-25 23:38       ` Aaron Ecay
  0 siblings, 1 reply; 7+ messages in thread
From: Jameson Graef Rollins @ 2011-07-25 20:53 UTC (permalink / raw)
  To: Aaron Ecay, notmuch

[-- Attachment #1: Type: text/plain, Size: 724 bytes --]

On Mon, 25 Jul 2011 16:33:09 -0400, Aaron Ecay <aaronecay@gmail.com> wrote:
> Signed-off-by: Aaron Ecay <aaronecay@gmail.com>

Hey, Aaron.  Thanks for submitting this patch.  However, you will need
to provide a more detailed log message in order for it to be pulled by
Carl.  The commit message should explain what exactly the problem is,
and how this fixes it.  You also don't need to add the "Signed-off-by"
for your own patches.

I also forgot to mention that if there is a way to test against the
issue that is raised here, then you should probably provide a patch to
the test suite as well.  Some bugs are just bugs, though, and there's
not really a reasonable way to test for them.  That may be the case
here.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Add missing call to g_type_init()
  2011-07-25 20:53     ` Jameson Graef Rollins
@ 2011-07-25 23:38       ` Aaron Ecay
  2011-07-26 17:57         ` Jameson Graef Rollins
  2011-09-10 18:22         ` David Bremner
  0 siblings, 2 replies; 7+ messages in thread
From: Aaron Ecay @ 2011-07-25 23:38 UTC (permalink / raw)
  To: notmuch

The Glib docs state "Prior to any use of the type system, g_type_init() has to
be called".[1] To not do so can lead to segfaults.  The g_type system is
currently used by various "filters" that operate on uuencoded text, message
headers, etc.

[1] http://developer.gnome.org/gobject/2.28/gobject-Type-Information.html#g-type-init

---

I have added a link to the Glib docs to the commit message, and a description
of where the type code is used.  There isn't an easy way to test for this bug,
I think -- not including the init call is wrong by the API docs, but only
sometimes yields a crash.

 notmuch.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/notmuch.c b/notmuch.c
index 3973e35..f9d6629 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -579,6 +579,7 @@ main (int argc, char *argv[])
     local = talloc_new (NULL);
 
     g_mime_init (0);
+    g_type_init ();
 
     if (argc == 1)
 	return notmuch (local);
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add missing call to g_type_init()
  2011-07-25 23:38       ` Aaron Ecay
@ 2011-07-26 17:57         ` Jameson Graef Rollins
  2011-09-10 18:22         ` David Bremner
  1 sibling, 0 replies; 7+ messages in thread
From: Jameson Graef Rollins @ 2011-07-26 17:57 UTC (permalink / raw)
  To: Aaron Ecay, notmuch

[-- Attachment #1: Type: text/plain, Size: 223 bytes --]

Hey, Aaron.  This patch looks good.  Thanks for resubmitting it.

So you say that this only sometimes yields a crash.  Do you know of any
way to trigger it?  I wonder why it causes a crash sometimes and not
others.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add missing call to g_type_init()
  2011-07-25 23:38       ` Aaron Ecay
  2011-07-26 17:57         ` Jameson Graef Rollins
@ 2011-09-10 18:22         ` David Bremner
  1 sibling, 0 replies; 7+ messages in thread
From: David Bremner @ 2011-09-10 18:22 UTC (permalink / raw)
  To: Aaron Ecay, notmuch

On Mon, 25 Jul 2011 19:38:58 -0400, Aaron Ecay <aaronecay@gmail.com> wrote:
> The Glib docs state "Prior to any use of the type system, g_type_init() has to
> be called".[1] To not do so can lead to segfaults.  The g_type system is
> currently used by various "filters" that operate on uuencoded text, message
> headers, etc.
> 
> [1] http://developer.gnome.org/gobject/2.28/gobject-Type-Information.html#g-type-init

I have pushed this patch. Thanks for your contribution.

d

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-09-10 18:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-24  4:32 segfault: g_type_init() missing Aaron Ecay
2011-07-24  5:51 ` Jameson Graef Rollins
2011-07-25 20:33   ` [PATCH] Add missing call to g_type_init() Aaron Ecay
2011-07-25 20:53     ` Jameson Graef Rollins
2011-07-25 23:38       ` Aaron Ecay
2011-07-26 17:57         ` Jameson Graef Rollins
2011-09-10 18:22         ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).