From owner-freebsd-current@FreeBSD.ORG Wed Oct 9 16:46:02 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 74A324F9 for ; Wed, 9 Oct 2013 16:46:02 +0000 (UTC) (envelope-from freebsd-listen@fabiankeil.de) Received: from smtprelay03.ispgateway.de (smtprelay03.ispgateway.de [80.67.31.26]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CD1DB24A5 for ; Wed, 9 Oct 2013 16:46:01 +0000 (UTC) Received: from [78.35.138.113] (helo=fabiankeil.de) by smtprelay03.ispgateway.de with esmtpsa (SSLv3:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1VTwik-0001kQ-6B for freebsd-current@freebsd.org; Wed, 09 Oct 2013 18:34:46 +0200 Date: Wed, 9 Oct 2013 18:34:46 +0200 From: Fabian Keil To: FreeBSD Current Subject: claws-mail deadlocking in iconv Message-ID: <73d40037.635a97ef@fabiankeil.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/nZJzfi+tvHOJV7AttwJY8NG"; protocol="application/pgp-signature" X-Df-Sender: Nzc1MDY3 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Oct 2013 16:46:02 -0000 --Sig_/nZJzfi+tvHOJV7AttwJY8NG Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable After the iconv import claws-mail started to deadlock in iconv every now and then on my system, which prevented claws-mail from rendering windows or reacting to input. So far I haven't been able to reproduce this intentionally and various rebuilds of ports, kernel and userland (mainly for other reasons) had no effect. When the problem occurs, trying to attach to the process causes gdb and gdb76 to crash which also crashes claws-mail, but sending SIGABRT causes a proper core dump that can be analysed with gdb. The backtraces always show that there is only one thread running and it's trying to lock cm_lock in _citrus_mapper_close(), which apparently is already locked due to a _citrus_mapper_close() recursion. Examples: #0 _umtx_op_err () at /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:= 37 37 RSYSCALL_ERR(_umtx_op) [New Thread 80a806400 (LWP 100487/claws-mail)] (gdb) where #0 _umtx_op_err () at /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:= 37 #1 0x00000008084861a6 in __thr_rwlock_wrlock (rwlock=3D0x80a8a47c0, tsp=3D= ) at /usr/src/lib/libthr/thread/thr_umtx.c:296 #2 0x0000000808489b1d in rwlock_wrlock_common (rwlock=3D, abstime=3D0x0) at /usr/src/lib/libthr/thread/thr_rwlock.c:267 #3 0x0000000808489a8b in _pthread_rwlock_wrlock (rwlock=3D0x80a8a47c0) at = /usr/src/lib/libthr/thread/thr_rwlock.c:289 #4 0x000000080911e848 in _citrus_mapper_close (cm=3D0x80b5a2d80) at /usr/s= rc/lib/libc/iconv/citrus_mapper.c:375 #5 0x000000080d205d18 in _citrus_mapper_serial_mapper_uninit (cm=3D0x80b5a= 2d40) at /usr/src/lib/libiconv_modules/mapper_parallel/../mapper_serial/cit= rus_mapper_serial.c:110 #6 0x000000080911e8d7 in mapper_close (cm=3D0x80b5a2d40) at /usr/src/lib/l= ibc/iconv/citrus_mapper.c:188 #7 0x000000080911e88c in _citrus_mapper_close (cm=3D)= at /usr/src/lib/libc/iconv/citrus_mapper.c:384 #8 0x000000080c4e83f3 in close_srcs (sl=3D0x80b591140) at /usr/src/lib/lib= iconv_modules/iconv_std/citrus_iconv_std.c:206 #9 0x000000080c4e7dc9 in _citrus_iconv_std_iconv_uninit_shared (ci=3D) at /usr/src/lib/libiconv_modules/iconv_std/citrus_iconv_s= td.c:415 #10 0x00000008090f3f95 in release_shared (ci=3D0x80a8ee630) at /usr/src/lib= /libc/iconv/citrus_iconv.c:99 #11 0x00000008090f4002 in _citrus_iconv_close (cv=3D0x80d88d5d0) at /usr/sr= c/lib/libc/iconv/citrus_iconv.c:335 #12 0x00000008090f1ca6 in iconv_close (handle=3D0x80a8a47c0) at /usr/src/li= b/libc/iconv/iconv.c:131 #13 0x000000000046376d in conv_iconv_strdup (inbuf=3D0x7fffffff58b0 "\n", s= rc_code=3D0x80b5b4db0 "Windows-1252", dest_code=3D0x6f03d0 "UTF-8") at code= conv.c:895 #14 0x0000000000463d13 in conv_convert (conv=3D0x80b5a4e80, outbuf=3D0x7fff= ffff3720 "", outlen=3D8192, inbuf=3D0x7fffffff58b0 "\n") at codeconv.c:734 #15 0x00000000005e22ac in textview_write_line (textview=3D0x80a959cc0, str= =3D0x7fffffff58b0 "\n", conv=3D0x80b5a4e80, do_quote_folding=3D1) at textvi= ew.c:1573 #16 0x00000000005df8e4 in textview_write_body (textview=3D0x80a959cc0, mime= info=3D0x80aad2d00) at textview.c:1177 #17 0x00000000005e5363 in textview_add_part (textview=3D0x80a959cc0, mimein= fo=3D0x80aad2d00) at textview.c:826 #18 0x00000000005e4053 in recursive_add_parts (textview=3D0x80a959cc0, node= =3D0x80a826190) at textview.c:839 #19 0x00000000005e4302 in recursive_add_parts (textview=3D0x80a959cc0, node= =3D0x80aa81d20) at textview.c:888 #20 0x00000000005e4302 in recursive_add_parts (textview=3D0x80a959cc0, node= =3D0x80a828890) at textview.c:888 #21 0x00000000005defa1 in textview_add_parts (textview=3D0x80a959cc0, mimei= nfo=3D0x80b610700) at textview.c:898 #22 0x00000000005deb85 in textview_show_part (textview=3D0x80a959cc0, mimei= nfo=3D0x80b610700, fp=3D0x8094319a0) at textview.c:645 [...] #0 0x0000000808491b9c in __error () from /lib/libthr.so.3 #1 0x000000080848bb1d in rwlock_wrlock_common (rwlock=3D, abstime=3D0x0) at /usr/src/lib/libthr/thread/thr_rwlock.c:267 #2 0x000000080848ba8b in _pthread_rwlock_wrlock (rwlock=3D0x80a8ede20) at = /usr/src/lib/libthr/thread/thr_rwlock.c:289 #3 0x000000080911f848 in _citrus_mapper_close (cm=3D0x80a8bfc40) at /usr/s= rc/lib/libc/iconv/citrus_mapper.c:375 #4 0x000000080ce02d18 in _citrus_mapper_serial_mapper_uninit (cm=3D0x80a8b= fc00) at /usr/src/lib/libiconv_modules/mapper_parallel/../mapper_serial/cit= rus_mapper_serial.c:110 #5 0x000000080911f8d7 in mapper_close (cm=3D0x80a8bfc00) at /usr/src/lib/l= ibc/iconv/citrus_mapper.c:188 #6 0x000000080911f88c in _citrus_mapper_close (cm=3D)= at /usr/src/lib/libc/iconv/citrus_mapper.c:384 #7 0x000000080c5893f3 in close_srcs (sl=3D0x80a8edda0) at /usr/src/lib/lib= iconv_modules/iconv_std/citrus_iconv_std.c:206 #8 0x000000080c588dc9 in _citrus_iconv_std_iconv_uninit_shared (ci=3D) at /usr/src/lib/libiconv_modules/iconv_std/citrus_iconv_s= td.c:415 #9 0x00000008090f4f95 in release_shared (ci=3D0x80b408890) at /usr/src/lib= /libc/iconv/citrus_iconv.c:99 #10 0x00000008090f5002 in _citrus_iconv_close (cv=3D0x80b782630) at /usr/sr= c/lib/libc/iconv/citrus_iconv.c:335 #11 0x00000008090f2ca6 in iconv_close (handle=3D0x80a8ede20) at /usr/src/li= b/libc/iconv/iconv.c:131 #12 0x000000000046376d in conv_iconv_strdup ( inbuf=3D0x80b600e00 "[...]"..., src_code=3D0x80b782640 "ISO-8859-15", d= est_code=3D0x80c07ab24 "UTF-8") at codeconv.c:895 #13 0x0000000000463f2f in conv_codeset_strdup ( inbuf=3D0x80b600e00 "[...]"..., src_code=3D0x80b782640 "ISO-8859-15", d= est_code=3D0x80c07ab24 "UTF-8") at codeconv.c:774 #14 0x000000080c07a1a7 in get_part_as_string (mimeinfo=3D0x80aad2d80) at pg= pinline.c:153 #15 0x000000080c078333 in pgpinline_is_encrypted (mimeinfo=3D0x80aad2d80) a= t pgpinline.c:375 [...] #0 _umtx_op_err () at /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:= 37 #1 0x00000008084861a6 in __thr_rwlock_wrlock (rwlock=3D0x80bf93f40, tsp=3D= ) at /usr/src/lib/libthr/thread/thr_umtx.c:296 #2 0x0000000808489b1d in rwlock_wrlock_common (rwlock=3D, abstime=3D0x0) at /usr/src/lib/libthr/thread/thr_rwlock.c:267 #3 0x0000000808489a8b in _pthread_rwlock_wrlock (rwlock=3D0x80bf93f40) at = /usr/src/lib/libthr/thread/thr_rwlock.c:289 #4 0x000000080911e848 in _citrus_mapper_close (cm=3D0x80bfa0b40) at /usr/s= rc/lib/libc/iconv/citrus_mapper.c:375 #5 0x000000080d08ad18 in _citrus_mapper_serial_mapper_uninit (cm=3D0x80bfa= 0b00) at /usr/src/lib/libiconv_modules/mapper_parallel/../mapper_serial/cit= rus_mapper_serial.c:110 #6 0x000000080911e8d7 in mapper_close (cm=3D0x80bfa0b00) at /usr/src/lib/l= ibc/iconv/citrus_mapper.c:188 #7 0x000000080911e88c in _citrus_mapper_close (cm=3D)= at /usr/src/lib/libc/iconv/citrus_mapper.c:384 #8 0x000000080ae2c3f3 in close_srcs (sl=3D0x80bf9fbc0) at /usr/src/lib/lib= iconv_modules/iconv_std/citrus_iconv_std.c:206 #9 0x000000080ae2bdc9 in _citrus_iconv_std_iconv_uninit_shared (ci=3D) at /usr/src/lib/libiconv_modules/iconv_std/citrus_iconv_s= td.c:415 #10 0x00000008090f3f95 in release_shared (ci=3D0x80bd59ac0) at /usr/src/lib= /libc/iconv/citrus_iconv.c:99 #11 0x00000008090f4002 in _citrus_iconv_close (cv=3D0x80dc1a3d0) at /usr/sr= c/lib/libc/iconv/citrus_iconv.c:335 #12 0x00000008090f1ca6 in iconv_close (handle=3D0x80bf93f40) at /usr/src/li= b/libc/iconv/iconv.c:131 #13 0x000000000046376d in conv_iconv_strdup (inbuf=3D0x80bd570c0 "[...]", s= rc_code=3D0x7fffffff5d60 "ISO-8859-2", dest_code=3D0x6f03d0 "UTF-8") at cod= econv.c:895 #14 0x0000000000463f2f in conv_codeset_strdup (inbuf=3D0x80bd570c0 "[...]",= src_code=3D0x7fffffff5d60 "ISO-8859-2", dest_code=3D0x0) at codeconv.c:774 #15 0x00000000005f63f0 in unmime_header (encoded_str=3D0x7fffffff7e94 "[...= ]", addr_field=3D1) at unmime.c:144 #16 0x0000000000464a56 in conv_unmime_header (str=3D0x7fffffff7e94 "[...]",= default_encoding=3D0x0, addr_field=3D1) at codeconv.c:1516 #17 0x000000000059588a in parse_stream (data=3D0x8094319a0, isstring=3D0, f= lags=3D{perm_flags =3D 3, tmp_flags =3D 0}, full=3D0, decrypted=3D0) at pro= cheader.c:558 #18 0x0000000000595234 in procheader_parse_stream (fp=3D0x8094319a0, flags= =3D{perm_flags =3D 3, tmp_flags =3D 0}, full=3D0, decrypted=3D0) at prochea= der.c:461 #19 0x0000000000595195 in procheader_parse_file (file=3D0x80d4202b0 "/home/= fk/.claws-mail/tempfolder/processing/18", flags=3D{perm_flags =3D 3, tmp_fl= ags =3D 0}, full=3D0, decrypted=3D0) at procheader.c:354 [...] This patch: http://www.fabiankeil.de/sourcecode/freebsd/iconv-Let-_citrus_mapper_close-= unlock-cm_lock-before-calli.diff seems to prevent the deadlock, but I'm not 100% sure that it's correct and I'm also a bit surprised by the lack of reports from other claws-mail users. Did anyone else run into this or can comment on the patch or the backtraces? Fabian --Sig_/nZJzfi+tvHOJV7AttwJY8NG Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (FreeBSD) iEYEARECAAYFAlJVhaYACgkQBYqIVf93VJ365gCfb+1VxEzL8gdNIfpbLwU9/Ijn o3UAoMApW2eZEkbJserHIH66TBoTPIbe =w4KR -----END PGP SIGNATURE----- --Sig_/nZJzfi+tvHOJV7AttwJY8NG--