Bug 1684 - view news messages with large attachements segfaults
Summary: view news messages with large attachements segfaults
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: NNTP (show other bugs)
Version: 3.9.0
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2008-07-28 17:52 UTC by Stephan Sachse
Modified: 2013-08-06 05:36 UTC (History)
0 users

See Also:


Attachments
bt from segfault (2.34 KB, text/plain)
2008-07-28 17:54 UTC, Stephan Sachse
no flags Details
bt full from segfault (4.86 KB, text/plain)
2008-07-28 17:55 UTC, Stephan Sachse
no flags Details
bt from segfault 3.5.0cvs37 (1.13 KB, text/plain)
2008-07-30 00:28 UTC, Stephan Sachse
no flags Details
bt full from segfault 3.5.0cvs37 (2.66 KB, text/plain)
2008-07-30 00:28 UTC, Stephan Sachse
no flags Details
valgrind memcheck (9.82 KB, text/plain)
2008-07-31 21:55 UTC, Stephan Sachse
no flags Details
new bt from abrt (16.30 KB, text/plain)
2010-04-05 15:42 UTC, Stephan Sachse
no flags Details
bt for 3.9.0 (3.16 KB, text/plain)
2013-04-19 09:39 UTC, Stephan Sachse
no flags Details
bt full for 3.9.0 (6.39 KB, text/plain)
2013-04-19 09:40 UTC, Stephan Sachse
no flags Details
Proposed fix (318 bytes, patch)
2013-04-19 10:39 UTC, Ricardo Mones
no flags Details | Diff

Description Stephan Sachse 2008-07-28 17:52:22 UTC
view a message with a large attachement (6127616 bytes) segfaults at the first time. second time (message is cached local) view this message works fine.

bt and bt full is attached
Comment 1 Stephan Sachse 2008-07-28 17:54:11 UTC
Created attachment 616 [details]
bt from segfault

bt
Comment 2 Stephan Sachse 2008-07-28 17:55:08 UTC
Created attachment 617 [details]
bt full from segfault

bt full
Comment 3 users 2008-07-29 08:35:43 UTC
Changes related to this bug have been committed.
Please check latest CVS and update the bug accordingly.
You can also get the patch from:
http://www.colino.net/claws-mail/

2008-07-29 [colin]	3.5.0cvs37

	* src/news.c
		Fix bug 1684, 'view news messages with large 
		attachements segfaults'
Comment 4 Stephan Sachse 2008-07-30 00:26:42 UTC
still segfaults bt and bt full
Comment 5 Stephan Sachse 2008-07-30 00:28:24 UTC
Created attachment 618 [details]
bt from segfault 3.5.0cvs37

bt from segfault 3.5.0cvs37
Comment 6 Stephan Sachse 2008-07-30 00:28:53 UTC
Created attachment 619 [details]
bt full from segfault 3.5.0cvs37

bt full from segfault 3.5.0cvs37
Comment 7 Colin Leroy 2008-07-30 13:36:13 UTC
Then it's probably a memory corruption error in libetpan. Can you install the debug symbols for libetpan, run with valgrind and send us the log?
Comment 8 Stephan Sachse 2008-07-31 21:55:46 UTC
Created attachment 620 [details]
valgrind memcheck

no crash with valgrind, the same posting segfaults CM without valgrind
Comment 9 Stephan Sachse 2008-08-03 12:09:27 UTC
the problem also exists in 3.3.0 with libetpan 0.54

btw: where are the release tarballs between 3.3.0 und 2.10.0 at sourceforge?
Comment 10 Stephan Sachse 2008-08-03 12:46:18 UTC
2.10.0, 3.0.0 works fine
3.1.0 segfaults
Comment 11 Stephan Sachse 2008-08-03 18:27:10 UTC
claws-mail-3.1.0 + libetpan-0.53 segfault
claws-mail-3.1.0 + libetpan-0.52 segfault
claws-mail-3.1.0 + libetpan-0.51 segfault

libetpan-0.50 (compiler error)
mailsmtp.c: In function 'sasl_getsecret':
mailsmtp.c:1101: warning: unused parameter 'conn'
mailsmtp.c: In function 'sasl_getrealm':
mailsmtp.c:1119: warning: unused parameter 'availrealms'
mailsmtp.c: In function 'mailesmtp_auth_sasl':
mailsmtp.c:1260: error: 'f' undeclared (first use in this function)
mailsmtp.c:1260: error: (Each undeclared identifier is reported only once
mailsmtp.c:1260: error: for each function it appears in.)

claws-mail-3.1.0 + libetpan-0.49 segfault
Comment 12 Colin Leroy 2008-08-06 23:06:20 UTC
This is a libetpan bug.
Comment 13 Stephan Sachse 2008-08-10 03:15:09 UTC
libetpan bug at sf.net is

  https://sourceforge.net/tracker/?func=detail&atid=429697&aid=2041394&group_id=41064

no response yet
Comment 14 Colin Leroy 2008-08-10 12:00:47 UTC
I think Hoa's on holidays :)
Comment 15 Stephan Sachse 2010-04-05 15:13:45 UTC
sf bug for libetpan closed...

  "This bug seems to be related to claws mail and not to libetpan."

https://sourceforge.net/tracker/?func=detail&atid=429697&aid=2041394&group_id=41064

problem still exists
Comment 16 Stephan Sachse 2010-04-05 15:42:37 UTC
Created attachment 828 [details]
new bt from abrt
Comment 17 Ricardo Mones 2013-04-18 17:25:23 UTC
There's new versions of Claws Mail and LibEtPan (and code in nntp.c has changed a lot), and the tracker with LibEtPan  bug doesn't exist anymore.

Is this still reproducible with a recent version?
Comment 18 Stephan Sachse 2013-04-18 23:27:02 UTC
still the same

segfaults if the message ist ~800KB

$ rpm -q claws-mail libetpan
claws-mail-3.9.0-1.fc18.i686
libetpan-1.1-3.fc18.i686
Comment 19 Ricardo Mones 2013-04-19 09:27:58 UTC
Same backtrace than the last one you posted? (3.5.0)
If possible attach the 3.9.0 backtrace.

thanks in advance,
Comment 20 Stephan Sachse 2013-04-19 09:39:13 UTC
Created attachment 1255 [details]
bt for 3.9.0
Comment 21 Stephan Sachse 2013-04-19 09:40:02 UTC
Created attachment 1256 [details]
bt full for 3.9.0
Comment 22 Ricardo Mones 2013-04-19 10:39:10 UTC
Created attachment 1257 [details]
Proposed fix

Thanks Sthephan for the backtraces.

From what I see following the code flow, the g_free(result); line causing the crash is wrong. The data returned into result in the end comes from a libEtPan's "str" member in a MMAPString structure, which is not allocated by glib functions but by the malloc/realloc functions (src/data-types/mmapstring.c in libEtPan).

Going a bit further, seems the MMAPString used for reading the article (see mailstream_read_multiline in mailstream_helper.c) is simply reused (first call is mmap_string_assign(multiline_buffer, "")), so the buffer is not intended to be freed by the caller.

To summarise, can build from 3.9.0 sources with the attached patch applied and see if it stops crashing? :)
Comment 23 Stephan Sachse 2013-05-01 15:03:09 UTC
sorry for delay!

probably-fix-1684.patch works for me with 3.9.0 :)
Comment 24 users 2013-05-02 09:32:04 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=f46d6934781359c0a4e6df3f78e74a799c883f4a
Author: Ricardo Mones <ricardo@mones.org>
Date:   Thu May 2 09:28:15 2013 +0200

    Fix bug #1684 'view news messages with large attachements segfaults'
    
    Don't g_free MMAPString str data which we didn't allocate

Note You need to log in before you can comment on or make changes to this bug.