[gmime-devel] using gmime in a multithreaded application
- From: Dan Streit <danws6 gmail com>
- To: gmime-devel-list gnome org
- Subject: [gmime-devel] using gmime in a multithreaded application
- Date: Fri, 19 Mar 2010 20:51:04 -0600
Hello,
I'm trying to use gmime in a multi threaded application but I am experience some segfaults when starting a lot of worker threads.
In my main thread I init the library:
g_mime_init (0);
in my worker threads I have:
GMimeMessage *message;
GMimeParser *parser;
GMimeStream *stream;
GMimeStream *stream_in;
Header hdr;
Body bdy;
stream = g_mime_stream_cat_new ();
hdr = priv->hhead;
while ( hdr != NULL )
{
stream_in = g_mime_stream_mem_new_with_buffer ( hdr->hdr_h, strlen( hdr->hdr_h ) );
g_mime_stream_cat_add_source ((GMimeStreamCat *) stream, stream_in);
g_object_unref(stream_in);
stream_in = g_mime_stream_mem_new_with_buffer ( ": ", 2 );
g_mime_stream_cat_add_source ((GMimeStreamCat *) stream, stream_in);
g_object_unref(stream_in);
stream_in = g_mime_stream_mem_new_with_buffer ( hdr->hdr_v, strlen( hdr->hdr_v ) );
g_mime_stream_cat_add_source ((GMimeStreamCat *) stream, stream_in);
g_object_unref(stream_in);
stream_in = g_mime_stream_mem_new_with_buffer ( "\r\n", 2 );
g_mime_stream_cat_add_source ((GMimeStreamCat *) stream, stream_in);
g_object_unref(stream_in);
hdr = hdr->hdr_next;
}
bdy = priv->bhead;
while ( bdy != NULL )
{
stream_in = g_mime_stream_mem_new_with_buffer (bdy->body_b, strlen(bdy->body_b));
g_mime_stream_cat_add_source ((GMimeStreamCat *) stream, stream_in);
g_object_unref(stream_in);
bdy = bdy->body_next;
}
if ( g_mime_stream_length( stream ) > 0 )
{
parser = g_mime_parser_new_with_stream (stream);
g_object_unref (stream);
message = g_mime_parser_construct_message (parser);
g_object_unref (parser);
g_mime_message_foreach (message, process_callback, user_data);
g_object_unref (message);
}
A few examples of some of the segfaults I've seen are:
t 86 (l 86) terminated by signal SEGV (no mapping at the fault address)
0xfef3209c: _g_slist_alloc+0x009e: movl 0x00000004(%ebx),%ecx
and
[1] magazine_chain_pop_head(0x80ddd98), at 0xfe6adf40
[2] thread_memory_magazine1_alloc(0x80ddd80, 0x2, 0xfe161298, 0xfe6ae5ff), at 0xfe6ae71a
[3] g_slice_alloc(0x14, 0x80e05f8, 0x80df6b8, 0xfef282cf, 0x8083f80, 0xfef2886a), at 0xfe6ae666
=>[4] event_list_add(list = (nil), callback = 0xfe1612c8, user_data = (nil)), line 109 in "internet-address.c"
[5] _internet_address_list_add(list = 0xfe1612f8, ia = (nil)), line 801 in "internet-address.c"
[6] internet_address_list_parse_string(str = 0x8084880 "
xxxx xxxxxx net"), line 1615 in "internet-address.c"
[7] message_add_recipients_from_string(message = (nil), action = "" type = GMIME_RECIPIENT_TYPE_TO, str = 0x8084880 "
xxxx xxxxxx net"), line 694 in "gmime-message.c"
[8] process_header(object = 0x80dd0e8, action = "" header = (nil), value = 0x8084880 "
xxxx xxxxxx net"), line 739 in "gmime-message.c"
[9] message_append_header(object = 0x80dd0e8, header = 0xfe1613b8 "\xe8^S^V\xfe\xf1!\xad\xfe\xe8\xd0^M^H\xb8\xfe^H^H\x80H^H^H^B", value = (nil)), line 809 in "gmime-message.c"
[10] g_mime_object_append_header(object = 0xfe1613e8, header = 0x808feb8 "To", value = (nil)), line 824 in "gmime-object.c"
[11] parser_construct_leaf_part(parser = 0x80e0298, content_type = 0xfe161438, found = 0xfe161468), line 1521 in "gmime-parser.c"
[12] parser_construct_multipart(parser = 0x80e0298, content_type = (nil), found = 0xfe1614b0), line 1695 in "gmime-parser.c"
[13] g_mime_parser_construct_message(parser = 0x80e0298), line 1863 in "gmime-parser.c"
Am I doing something wrong or is this possibly an environment issue?
Solaris 10
gcc 3.4.6
glib 2.20.4
gmime 2.4.15
Thanks,
Dan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]