Date: Thu, 10 Oct 2013 21:52:06 +0200 From: Tijl Coosemans <tijl@coosemans.org> To: Fabian Keil <freebsd-listen@fabiankeil.de> Cc: freebsd-current@freebsd.org, peter@freebsd.org Subject: Re: claws-mail deadlocking in iconv Message-ID: <20131010215206.2e0896df@kalimero.tijl.coosemans.org> In-Reply-To: <73d40037.635a97ef@fabiankeil.de> References: <73d40037.635a97ef@fabiankeil.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_/Jj6CG1SxWjQpcL54frLwbB3 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 9 Oct 2013 18:34:46 +0200 Fabian Keil wrote: > 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. >=20 > 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. >=20 > 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. >=20 > 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: >=20 > #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<value optimized out>) at /usr/src/lib/libthr/thread/thr_umtx.c:296 > #2 0x0000000808489b1d in rwlock_wrlock_common (rwlock=3D<value optimized= out>, abstime=3D0x0) at /usr/src/lib/libthr/thread/thr_rwlock.c:267 > #3 0x0000000808489a8b in _pthread_rwlock_wrlock (rwlock=3D0x80a8a47c0) a= t /usr/src/lib/libthr/thread/thr_rwlock.c:289 > #4 0x000000080911e848 in _citrus_mapper_close (cm=3D0x80b5a2d80) at /usr= /src/lib/libc/iconv/citrus_mapper.c:375 > #5 0x000000080d205d18 in _citrus_mapper_serial_mapper_uninit (cm=3D0x80b= 5a2d40) at /usr/src/lib/libiconv_modules/mapper_parallel/../mapper_serial/c= itrus_mapper_serial.c:110 > #6 0x000000080911e8d7 in mapper_close (cm=3D0x80b5a2d40) at /usr/src/lib= /libc/iconv/citrus_mapper.c:188 > #7 0x000000080911e88c in _citrus_mapper_close (cm=3D<value optimized out= >) at /usr/src/lib/libc/iconv/citrus_mapper.c:384 > #8 0x000000080c4e83f3 in close_srcs (sl=3D0x80b591140) at /usr/src/lib/l= ibiconv_modules/iconv_std/citrus_iconv_std.c:206 > #9 0x000000080c4e7dc9 in _citrus_iconv_std_iconv_uninit_shared (ci=3D<va= lue optimized out>) at /usr/src/lib/libiconv_modules/iconv_std/citrus_iconv= _std.c:415 > #10 0x00000008090f3f95 in release_shared (ci=3D0x80a8ee630) at /usr/src/l= ib/libc/iconv/citrus_iconv.c:99 > #11 0x00000008090f4002 in _citrus_iconv_close (cv=3D0x80d88d5d0) at /usr/= src/lib/libc/iconv/citrus_iconv.c:335 > #12 0x00000008090f1ca6 in iconv_close (handle=3D0x80a8a47c0) at /usr/src/= lib/libc/iconv/iconv.c:131 > #13 0x000000000046376d in conv_iconv_strdup (inbuf=3D0x7fffffff58b0 "\n",= src_code=3D0x80b5b4db0 "Windows-1252", dest_code=3D0x6f03d0 "UTF-8") at co= deconv.c:895 > #14 0x0000000000463d13 in conv_convert (conv=3D0x80b5a4e80, outbuf=3D0x7f= ffffff3720 "", outlen=3D8192, inbuf=3D0x7fffffff58b0 "\n") at codeconv.c:734 > #15 0x00000000005e22ac in textview_write_line (textview=3D0x80a959cc0, st= r=3D0x7fffffff58b0 "\n", conv=3D0x80b5a4e80, do_quote_folding=3D1) at textv= iew.c:1573 > #16 0x00000000005df8e4 in textview_write_body (textview=3D0x80a959cc0, mi= meinfo=3D0x80aad2d00) at textview.c:1177 > #17 0x00000000005e5363 in textview_add_part (textview=3D0x80a959cc0, mime= info=3D0x80aad2d00) at textview.c:826 > #18 0x00000000005e4053 in recursive_add_parts (textview=3D0x80a959cc0, no= de=3D0x80a826190) at textview.c:839 > #19 0x00000000005e4302 in recursive_add_parts (textview=3D0x80a959cc0, no= de=3D0x80aa81d20) at textview.c:888 > #20 0x00000000005e4302 in recursive_add_parts (textview=3D0x80a959cc0, no= de=3D0x80a828890) at textview.c:888 > #21 0x00000000005defa1 in textview_add_parts (textview=3D0x80a959cc0, mim= einfo=3D0x80b610700) at textview.c:898 > #22 0x00000000005deb85 in textview_show_part (textview=3D0x80a959cc0, mim= einfo=3D0x80b610700, fp=3D0x8094319a0) at textview.c:645 > [...] >=20 > #0 0x0000000808491b9c in __error () from /lib/libthr.so.3 > #1 0x000000080848bb1d in rwlock_wrlock_common (rwlock=3D<value optimized= out>, abstime=3D0x0) at /usr/src/lib/libthr/thread/thr_rwlock.c:267 > #2 0x000000080848ba8b in _pthread_rwlock_wrlock (rwlock=3D0x80a8ede20) a= t /usr/src/lib/libthr/thread/thr_rwlock.c:289 > #3 0x000000080911f848 in _citrus_mapper_close (cm=3D0x80a8bfc40) at /usr= /src/lib/libc/iconv/citrus_mapper.c:375 > #4 0x000000080ce02d18 in _citrus_mapper_serial_mapper_uninit (cm=3D0x80a= 8bfc00) at /usr/src/lib/libiconv_modules/mapper_parallel/../mapper_serial/c= itrus_mapper_serial.c:110 > #5 0x000000080911f8d7 in mapper_close (cm=3D0x80a8bfc00) at /usr/src/lib= /libc/iconv/citrus_mapper.c:188 > #6 0x000000080911f88c in _citrus_mapper_close (cm=3D<value optimized out= >) at /usr/src/lib/libc/iconv/citrus_mapper.c:384 > #7 0x000000080c5893f3 in close_srcs (sl=3D0x80a8edda0) at /usr/src/lib/l= ibiconv_modules/iconv_std/citrus_iconv_std.c:206 > #8 0x000000080c588dc9 in _citrus_iconv_std_iconv_uninit_shared (ci=3D<va= lue optimized out>) at /usr/src/lib/libiconv_modules/iconv_std/citrus_iconv= _std.c:415 > #9 0x00000008090f4f95 in release_shared (ci=3D0x80b408890) at /usr/src/l= ib/libc/iconv/citrus_iconv.c:99 > #10 0x00000008090f5002 in _citrus_iconv_close (cv=3D0x80b782630) at /usr/= src/lib/libc/iconv/citrus_iconv.c:335 > #11 0x00000008090f2ca6 in iconv_close (handle=3D0x80a8ede20) at /usr/src/= lib/libc/iconv/iconv.c:131 > #12 0x000000000046376d in conv_iconv_strdup ( > inbuf=3D0x80b600e00 "[...]"..., src_code=3D0x80b782640 "ISO-8859-15",= dest_code=3D0x80c07ab24 "UTF-8") at codeconv.c:895 > #13 0x0000000000463f2f in conv_codeset_strdup ( > inbuf=3D0x80b600e00 "[...]"..., src_code=3D0x80b782640 "ISO-8859-15",= dest_code=3D0x80c07ab24 "UTF-8") at codeconv.c:774 > #14 0x000000080c07a1a7 in get_part_as_string (mimeinfo=3D0x80aad2d80) at = pgpinline.c:153 > #15 0x000000080c078333 in pgpinline_is_encrypted (mimeinfo=3D0x80aad2d80)= at pgpinline.c:375 > [...] >=20 > #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<value optimized out>) at /usr/src/lib/libthr/thread/thr_umtx.c:296 > #2 0x0000000808489b1d in rwlock_wrlock_common (rwlock=3D<value optimized= out>, abstime=3D0x0) at /usr/src/lib/libthr/thread/thr_rwlock.c:267 > #3 0x0000000808489a8b in _pthread_rwlock_wrlock (rwlock=3D0x80bf93f40) a= t /usr/src/lib/libthr/thread/thr_rwlock.c:289 > #4 0x000000080911e848 in _citrus_mapper_close (cm=3D0x80bfa0b40) at /usr= /src/lib/libc/iconv/citrus_mapper.c:375 > #5 0x000000080d08ad18 in _citrus_mapper_serial_mapper_uninit (cm=3D0x80b= fa0b00) at /usr/src/lib/libiconv_modules/mapper_parallel/../mapper_serial/c= itrus_mapper_serial.c:110 > #6 0x000000080911e8d7 in mapper_close (cm=3D0x80bfa0b00) at /usr/src/lib= /libc/iconv/citrus_mapper.c:188 > #7 0x000000080911e88c in _citrus_mapper_close (cm=3D<value optimized out= >) at /usr/src/lib/libc/iconv/citrus_mapper.c:384 > #8 0x000000080ae2c3f3 in close_srcs (sl=3D0x80bf9fbc0) at /usr/src/lib/l= ibiconv_modules/iconv_std/citrus_iconv_std.c:206 > #9 0x000000080ae2bdc9 in _citrus_iconv_std_iconv_uninit_shared (ci=3D<va= lue optimized out>) at /usr/src/lib/libiconv_modules/iconv_std/citrus_iconv= _std.c:415 > #10 0x00000008090f3f95 in release_shared (ci=3D0x80bd59ac0) at /usr/src/l= ib/libc/iconv/citrus_iconv.c:99 > #11 0x00000008090f4002 in _citrus_iconv_close (cv=3D0x80dc1a3d0) at /usr/= src/lib/libc/iconv/citrus_iconv.c:335 > #12 0x00000008090f1ca6 in iconv_close (handle=3D0x80bf93f40) at /usr/src/= lib/libc/iconv/iconv.c:131 > #13 0x000000000046376d in conv_iconv_strdup (inbuf=3D0x80bd570c0 "[...]",= src_code=3D0x7fffffff5d60 "ISO-8859-2", dest_code=3D0x6f03d0 "UTF-8") at c= odeconv.c:895 > #14 0x0000000000463f2f in conv_codeset_strdup (inbuf=3D0x80bd570c0 "[...]= ", src_code=3D0x7fffffff5d60 "ISO-8859-2", dest_code=3D0x0) at codeconv.c:7= 74 > #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,= flags=3D{perm_flags =3D 3, tmp_flags =3D 0}, full=3D0, decrypted=3D0) at p= rocheader.c:558 > #18 0x0000000000595234 in procheader_parse_stream (fp=3D0x8094319a0, flag= s=3D{perm_flags =3D 3, tmp_flags =3D 0}, full=3D0, decrypted=3D0) at proche= ader.c:461 > #19 0x0000000000595195 in procheader_parse_file (file=3D0x80d4202b0 "/hom= e/fk/.claws-mail/tempfolder/processing/18", flags=3D{perm_flags =3D 3, tmp_= flags =3D 0}, full=3D0, decrypted=3D0) at procheader.c:354 > [...] >=20 > This patch: > http://www.fabiankeil.de/sourcecode/freebsd/iconv-Let-_citrus_mapper_clos= e-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 use= rs. >=20 > Did anyone else run into this or can comment on the patch or > the backtraces? I've been using the patch all day now and the deadlocks seem to have disappeared. I've CCed Peter Wemm who worked on the locking in libc iconv. Besides the case in the patch there's a _mapper_close call on line 350 in the same file that should be looked at as well. --Sig_/Jj6CG1SxWjQpcL54frLwbB3 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (FreeBSD) iF4EAREKAAYFAlJXBWsACgkQfoCS2CCgtivhAAD/TyqkK2uiBd+EWJ0r2MqZCDmX IhaLdbYk8KHe6n8bMMYA/0resZEYwPuDHVvsRmtJEW18YZ75aIsqTPUWWM3p8WbE =RAuk -----END PGP SIGNATURE----- --Sig_/Jj6CG1SxWjQpcL54frLwbB3--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20131010215206.2e0896df>