[gmime-devel] g_mime_parser_construct_message() segfaults (GMime 3.0.1)



Hello,

I don't know if I do something wrong in my small program, if the library was compiled wrong, or if there is a real bug in the library. The use case looks very simple, and the few e-mail files I tested are extremely basic and short, so I doubt it could be a library bug; but anyway, I ask my question hoping you can enlighten me.

The e-mail files were generated by another program of mine which took a mbox, extract the date, split its content as individual messages and wrote each of them in a separate file with g_mime_object_write_to_stream(). It used g_mime_parser_construct_message() too and went fine.

Here are the faulty test program and its trace (if needed, I will send the e-mail in private if possible):

==================================

stephane@zbox ~/test/gmime $ cat segfault_g_mime_parser_construct_message.c
#include <stdio.h>
#include <gmime-3.0/gmime/gmime.h>

int main(int argc, char **argv) {
        int ret=0;
        GError *gerr;
        GMimeMessage *message;
        GMimeStream *stream;
        GMimeParser *parser;

        printf("Uninitialised stream=%p\n", stream);
        stream=g_mime_stream_file_open("2014-05-29_14:50:13-1.msg", "r", &gerr);
        printf("stream=%p\n", stream);
        if(!stream) {
                fprintf(stderr, "Unable to open GMime stream for reading 2014-05-29_14:50:13-1.msg : s\n", 
gerr->message);
                ret=-3;
                goto clean;
        }
        printf("Uninitialised parser=%p\n", parser);
        parser=g_mime_parser_new_with_stream(stream);
        printf("parser=%p\n", parser);
        g_mime_parser_set_format(parser, GMIME_FORMAT_MESSAGE);
        printf("BEFORE, parser=%p\n", parser);
        if(message=g_mime_parser_construct_message(parser, GMIME_RFC_COMPLIANCE_LOOSE)) {
                printf("INSIDE\n");
        }
        printf("AFTER, parser=%p\n", parser);

clean:
        return ret;
}

stephane@zbox ~/test/gmime $ make
gcc -std=c99 -Werror `pkg-config --cflags glib-2.0` `pkg-config --cflags gmime-3.0` -c 
segfault_g_mime_parser_construct_message.c
gcc `pkg-config --libs glib-2.0` `pkg-config --libs gmime-3.0` segfault_g_mime_parser_construct_message.o -o 
segfault_g_mime_parser_construct_message
stephane@zbox ~/test/gmime $ gdb ./segfault_g_mime_parser_construct_message
GNU gdb (Gentoo 8.0 vanilla) 8.0
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./segfault_g_mime_parser_construct_message...(no debugging symbols found)...done.
(gdb) run
Starting program: /home/stephane/test/gmime/segfault_g_mime_parser_construct_message
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Uninitialised stream=0x4009f0
stream=0x60ec00
Uninitialised parser=0x4007a0
parser=0x60f600
BEFORE, parser=0x60f600

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff78842d9 in g_mime_parser_options_clone () from /usr/lib64/libgmime-3.0.so.0
(gdb) bt
#0  0x00007ffff78842d9 in g_mime_parser_options_clone () from /usr/lib64/libgmime-3.0.so.0
#1  0x00007ffff7876995 in g_mime_header_list_new () from /usr/lib64/libgmime-3.0.so.0
#2  0x00007ffff787c806 in g_mime_object_init () from /usr/lib64/libgmime-3.0.so.0
#3  0x00007ffff72992bf in g_type_create_instance () from /usr/lib64/libgobject-2.0.so.0
#4  0x00007ffff727b19b in g_object_new_internal () from /usr/lib64/libgobject-2.0.so.0
#5  0x00007ffff727cbad in g_object_newv () from /usr/lib64/libgobject-2.0.so.0
#6  0x00007ffff727d344 in g_object_new () from /usr/lib64/libgobject-2.0.so.0
#7  0x00007ffff7878c6d in g_mime_message_new () from /usr/lib64/libgmime-3.0.so.0
#8  0x00007ffff7883e72 in g_mime_parser_construct_message () from /usr/lib64/libgmime-3.0.so.0
#9  0x00000000004009a9 in main ()
(gdb)


==================================

Goodbye,
  Stéphane.


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