Return-Path: MIME-Version: 1.0 In-Reply-To: References: <4C46324D.5070800@aircable.net> <20100721101934.GA12188@jh-x301> <4C470E2D.7000607@aircable.net> Date: Wed, 28 Jul 2010 17:55:35 +0300 Message-ID: Subject: Re: [PATCH][RFC] Fix SDP resolving segfault From: Luiz Augusto von Dentz To: Manuel Naranjo Cc: Johan Hedberg , BlueZ Content-Type: multipart/mixed; boundary=00163646ba4e616a5a048c73cfa0 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: --00163646ba4e616a5a048c73cfa0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Manuel, On Fri, Jul 23, 2010 at 11:37 PM, Luiz Augusto von Dentz wrote: > Hi, > > On Wed, Jul 21, 2010 at 6:11 PM, Manuel Naranjo wro= te: >> I think this is the one that really fix the problem. I see connect_watch >> getting called and then getting into the crash. I have a nice log with t= he >> tracing feature I sent the other day, here's the end of it (the hole thi= ng >> is almost 40 megs if someone wants just ask for it). > > I just figure out that our connect_watch in glib_helper.c is not quite > right, it should be something similar as we have btio.c, specially > this one is particular important: > > =A0 =A0 =A0 =A0/* If the user aborted this connect attempt */ > =A0 =A0 =A0 =A0if ((cond & G_IO_NVAL) || check_nval(io)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return FALSE; > > It is probably because of not having this check that the cb is still > called after bt_cancel_discovery. Of course this doesn't invalidate > your fix to bt_cancel_discovery itself, but I guess this should also > be included to safe that the callback is not called after cancelling > the discovery. Can you try the patch attached to this email? --=20 Luiz Augusto von Dentz Computer Engineer --00163646ba4e616a5a048c73cfa0 Content-Type: text/x-patch; charset=US-ASCII; name="0001-core-fix-not-handling-sdp-connection-errors-properly.patch" Content-Disposition: attachment; filename="0001-core-fix-not-handling-sdp-connection-errors-properly.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gc6ah1jv0 RnJvbSAyODk1M2Y1YjQxOTY5M2Q4MjgxZjA1NzA1NWEzNGQ5YmMzZTQ0NDJlIE1v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