[{"id":16232,"web_url":"https://patchwork.libcamera.org/comment/16232/","msgid":"<64469444-832f-4a64-e4c5-3196f5b78502@ideasonboard.com>","date":"2021-04-13T13:02:46","subject":"Re: [libcamera-devel] [PATCH/RFC] libcamera: bound_method: Please\n\tgcc undefined behaviour sanitizer","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\n$SUBJECT might need improving ;-)\n\nOn 12/04/2021 23:59, Laurent Pinchart wrote:\n> Enabling the gcc undefined behaviour sanitizer (with the meson configure\n> -Db_sanitize=undefined option) causes many tests to fail, with errors\n> such as the following (for test/object-invoke):\n> \n> ../../include/libcamera/bound_method.h:198:27: runtime error: member access within address 0x55fcd7bfbd38 which does not point to an object of type 'BoundMethodBase'\n> 0x55fcd7bfbd38: note: object has invalid vptr\n>  fc 55 00 00  2a 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  31 00 00 00 00 00 00 00  4b c6 72 88\n>               ^~~~~~~~~~~~~~~~~~~~~~~\n>               invalid vptr\n> ../../include/libcamera/bound_method.h:198:41: runtime error: member call on null pointer of type 'struct InvokedObject'\n> ../../include/libcamera/bound_method.h:198:41: runtime error: member access within null pointer of type 'struct InvokedObject'\n> Segmentation fault\n> \n> The root cause isn't clear, but this change fixes the issue. It may be a\n> bug in gcc.\n\nGiven that this is just a small semantic change to separate the casting\nof the object, and the calling, I don't think there's any harm in\napplying this as is, given that even if we fix GCC we'd have to wait for\nit to filter down?\n\nHowever I have no real understanding of the underlying issues either I'm\nafraid, so I don't think I can help ...\n\nIs it easy to reduce it down to a reproducible issue?\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/bound_method.h | 6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n> \n> If anyone is interested in trying the gcc undefined behaviour sanitizer,\n> this patch is needed. Bonus points if you can spot why it helps.\n> \n> diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h\n> index f216e3b56826..de17fdee3612 100644\n> --- a/include/libcamera/bound_method.h\n> +++ b/include/libcamera/bound_method.h\n> @@ -163,7 +163,8 @@ public:\n>  \n>  \tR invoke(Args... args) override\n>  \t{\n> -\t\treturn (static_cast<T *>(this->obj_)->*func_)(args...);\n> +\t\tT *obj = static_cast<T *>(this->obj_);\n> +\t\treturn (obj->*func_)(args...);\n>  \t}\n>  \n>  private:\n> @@ -195,7 +196,8 @@ public:\n>  \n>  \tvoid invoke(Args... args) override\n>  \t{\n> -\t\t(static_cast<T *>(this->obj_)->*func_)(args...);\n> +\t\tT *obj = static_cast<T *>(this->obj_);\n> +\t\t(obj->*func_)(args...);\n>  \t}\n>  \n>  private:\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 79F15BD1F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Apr 2021 13:02:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E7EBE687FE;\n\tTue, 13 Apr 2021 15:02:51 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F712602D1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Apr 2021 15:02:51 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7CA468AF;\n\tTue, 13 Apr 2021 15:02:49 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"rZgvplSr\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1618318970;\n\tbh=0B22rne+48LvphVmCDalLxpoD+OGIZZ7DTAIwgE+o6E=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=rZgvplSrUdIqaBhoZ52q6yTf+x9dJBd8fvMvGWgLvBDxNynCRN5tCydjcQuaU+uuW\n\tfEyce0TsUKEpMts/Mb47Orot7r81G7adE0WrZyBn3GUqXB6kFlBPVPS1sehmWDK0Ya\n\tZyW63L1o9EMdpwUL9bW2IevM+FBEwySdXKg2mvy8=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210412225948.13796-1-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRyOBzL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kh80ZKNBFddx1AabQpSVQKbdcLb8OFs85kuSvFdgqZwgxA1vl4TFhNz\n\tPZ79NAmXLackAx3sOVFhk4WQaKRshCB7cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp\n\tECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx\n\tS0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j\n\tsbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8\n\tpQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc\n\tMW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU\n\tAfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<64469444-832f-4a64-e4c5-3196f5b78502@ideasonboard.com>","Date":"Tue, 13 Apr 2021 14:02:46 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<20210412225948.13796-1-laurent.pinchart@ideasonboard.com>","Content-Language":"en-GB","Subject":"Re: [libcamera-devel] [PATCH/RFC] libcamera: bound_method: Please\n\tgcc undefined behaviour sanitizer","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Reply-To":"kieran.bingham@ideasonboard.com","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16239,"web_url":"https://patchwork.libcamera.org/comment/16239/","msgid":"<YHYA2XOQYYG5/2fY@pendragon.ideasonboard.com>","date":"2021-04-13T20:36:41","subject":"Re: [libcamera-devel] [PATCH/RFC] libcamera: bound_method: Please\n\tgcc undefined behaviour sanitizer","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nOn Tue, Apr 13, 2021 at 02:02:46PM +0100, Kieran Bingham wrote:\n> Hi Laurent,\n> \n> $SUBJECT might need improving ;-)\n\ns/Please/Please the/ ?\n\n> On 12/04/2021 23:59, Laurent Pinchart wrote:\n> > Enabling the gcc undefined behaviour sanitizer (with the meson configure\n> > -Db_sanitize=undefined option) causes many tests to fail, with errors\n> > such as the following (for test/object-invoke):\n> > \n> > ../../include/libcamera/bound_method.h:198:27: runtime error: member access within address 0x55fcd7bfbd38 which does not point to an object of type 'BoundMethodBase'\n> > 0x55fcd7bfbd38: note: object has invalid vptr\n> >  fc 55 00 00  2a 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  31 00 00 00 00 00 00 00  4b c6 72 88\n> >               ^~~~~~~~~~~~~~~~~~~~~~~\n> >               invalid vptr\n> > ../../include/libcamera/bound_method.h:198:41: runtime error: member call on null pointer of type 'struct InvokedObject'\n> > ../../include/libcamera/bound_method.h:198:41: runtime error: member access within null pointer of type 'struct InvokedObject'\n> > Segmentation fault\n> > \n> > The root cause isn't clear, but this change fixes the issue. It may be a\n> > bug in gcc.\n> \n> Given that this is just a small semantic change to separate the casting\n> of the object, and the calling, I don't think there's any harm in\n> applying this as is, given that even if we fix GCC we'd have to wait for\n> it to filter down?\n\nI agree.\n\n> However I have no real understanding of the underlying issues either I'm\n> afraid, so I don't think I can help ...\n> \n> Is it easy to reduce it down to a reproducible issue?\n\nIt's lots of template code, so it may not be that easy. I haven't tried\nyet. Ideally we should file a bug with gcc.\n\n> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  include/libcamera/bound_method.h | 6 ++++--\n> >  1 file changed, 4 insertions(+), 2 deletions(-)\n> > \n> > If anyone is interested in trying the gcc undefined behaviour sanitizer,\n> > this patch is needed. Bonus points if you can spot why it helps.\n> > \n> > diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h\n> > index f216e3b56826..de17fdee3612 100644\n> > --- a/include/libcamera/bound_method.h\n> > +++ b/include/libcamera/bound_method.h\n> > @@ -163,7 +163,8 @@ public:\n> >  \n> >  \tR invoke(Args... args) override\n> >  \t{\n> > -\t\treturn (static_cast<T *>(this->obj_)->*func_)(args...);\n> > +\t\tT *obj = static_cast<T *>(this->obj_);\n> > +\t\treturn (obj->*func_)(args...);\n> >  \t}\n> >  \n> >  private:\n> > @@ -195,7 +196,8 @@ public:\n> >  \n> >  \tvoid invoke(Args... args) override\n> >  \t{\n> > -\t\t(static_cast<T *>(this->obj_)->*func_)(args...);\n> > +\t\tT *obj = static_cast<T *>(this->obj_);\n> > +\t\t(obj->*func_)(args...);\n> >  \t}\n> >  \n> >  private:\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DAA87BD1F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Apr 2021 20:37:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 564B4602D1;\n\tTue, 13 Apr 2021 22:37:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 82781602D1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Apr 2021 22:37:32 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E68FB9F0;\n\tTue, 13 Apr 2021 22:37:31 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"GGDXYj8x\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1618346252;\n\tbh=ahd/UV0dmfgu//fpk7DLGU6knVJVt/3vLMMacNfEQic=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=GGDXYj8xLMX57unnL8D5LZrQNgCi0cBbidVSeps6vPlIkeh7LcqWuc1Z/vIVNL6fR\n\tjQCTPC95hr9T3b55WJtWaAJ9fieF9Oz0eaSdQy1r4KLXAVPAgA+S1jon+XSKL20Hs6\n\tO0L/73P2aLDn2Q4Un6BuoXgsX8v0OcFm2N3fenjc=","Date":"Tue, 13 Apr 2021 23:36:41 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YHYA2XOQYYG5/2fY@pendragon.ideasonboard.com>","References":"<20210412225948.13796-1-laurent.pinchart@ideasonboard.com>\n\t<64469444-832f-4a64-e4c5-3196f5b78502@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<64469444-832f-4a64-e4c5-3196f5b78502@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH/RFC] libcamera: bound_method: Please\n\tgcc undefined behaviour sanitizer","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16240,"web_url":"https://patchwork.libcamera.org/comment/16240/","msgid":"<fba45ad3-3c84-3e37-fceb-7a8335eb95fc@ideasonboard.com>","date":"2021-04-13T20:40:39","subject":"Re: [libcamera-devel] [PATCH/RFC] libcamera: bound_method: Please\n\tgcc undefined behaviour sanitizer","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 13/04/2021 21:36, Laurent Pinchart wrote:\n> Hi Kieran,\n> \n> On Tue, Apr 13, 2021 at 02:02:46PM +0100, Kieran Bingham wrote:\n>> Hi Laurent,\n>>\n>> $SUBJECT might need improving ;-)\n> \n> s/Please/Please the/ ?\n\nAha, yes - now I understand what you meant!\n\nIt looks like some sort of odd malformed request otherwise.\n--\nKieran\n\n\n\n>> On 12/04/2021 23:59, Laurent Pinchart wrote:\n>>> Enabling the gcc undefined behaviour sanitizer (with the meson configure\n>>> -Db_sanitize=undefined option) causes many tests to fail, with errors\n>>> such as the following (for test/object-invoke):\n>>>\n>>> ../../include/libcamera/bound_method.h:198:27: runtime error: member access within address 0x55fcd7bfbd38 which does not point to an object of type 'BoundMethodBase'\n>>> 0x55fcd7bfbd38: note: object has invalid vptr\n>>>  fc 55 00 00  2a 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  31 00 00 00 00 00 00 00  4b c6 72 88\n>>>               ^~~~~~~~~~~~~~~~~~~~~~~\n>>>               invalid vptr\n>>> ../../include/libcamera/bound_method.h:198:41: runtime error: member call on null pointer of type 'struct InvokedObject'\n>>> ../../include/libcamera/bound_method.h:198:41: runtime error: member access within null pointer of type 'struct InvokedObject'\n>>> Segmentation fault\n>>>\n>>> The root cause isn't clear, but this change fixes the issue. It may be a\n>>> bug in gcc.\n>>\n>> Given that this is just a small semantic change to separate the casting\n>> of the object, and the calling, I don't think there's any harm in\n>> applying this as is, given that even if we fix GCC we'd have to wait for\n>> it to filter down?\n> \n> I agree.\n> \n>> However I have no real understanding of the underlying issues either I'm\n>> afraid, so I don't think I can help ...\n>>\n>> Is it easy to reduce it down to a reproducible issue?\n> \n> It's lots of template code, so it may not be that easy. I haven't tried\n> yet. Ideally we should file a bug with gcc.\n> \n>> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>>\n>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>>> ---\n>>>  include/libcamera/bound_method.h | 6 ++++--\n>>>  1 file changed, 4 insertions(+), 2 deletions(-)\n>>>\n>>> If anyone is interested in trying the gcc undefined behaviour sanitizer,\n>>> this patch is needed. Bonus points if you can spot why it helps.\n>>>\n>>> diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h\n>>> index f216e3b56826..de17fdee3612 100644\n>>> --- a/include/libcamera/bound_method.h\n>>> +++ b/include/libcamera/bound_method.h\n>>> @@ -163,7 +163,8 @@ public:\n>>>  \n>>>  \tR invoke(Args... args) override\n>>>  \t{\n>>> -\t\treturn (static_cast<T *>(this->obj_)->*func_)(args...);\n>>> +\t\tT *obj = static_cast<T *>(this->obj_);\n>>> +\t\treturn (obj->*func_)(args...);\n>>>  \t}\n>>>  \n>>>  private:\n>>> @@ -195,7 +196,8 @@ public:\n>>>  \n>>>  \tvoid invoke(Args... args) override\n>>>  \t{\n>>> -\t\t(static_cast<T *>(this->obj_)->*func_)(args...);\n>>> +\t\tT *obj = static_cast<T *>(this->obj_);\n>>> +\t\t(obj->*func_)(args...);\n>>>  \t}\n>>>  \n>>>  private:\n>>>\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D2DBFBD224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Apr 2021 20:40:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8DB19687D6;\n\tTue, 13 Apr 2021 22:40:44 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CE70E602D1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Apr 2021 22:40:42 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5A749AF3;\n\tTue, 13 Apr 2021 22:40:42 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"vcUXtrs+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1618346442;\n\tbh=RGMHQLKgDIqP466tK9J2PPKbFzViOVCHhIq0mo4xnO4=;\n\th=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=vcUXtrs+JHi5p760bBd86XT2VLTgyDmtqIg7Oq70Kt+pEftRrqCpSUBzGl5lcIF1y\n\tVEQKMZ0hIeJFQEH1BX10kc6BXvZOV2o//Kq682zXclPslsAky1wCxRwTcgjutelktd\n\ttQ8BZrxC7jtTkhXSgJNViYjODWjEjHi+1Uk9K8M0=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20210412225948.13796-1-laurent.pinchart@ideasonboard.com>\n\t<64469444-832f-4a64-e4c5-3196f5b78502@ideasonboard.com>\n\t<YHYA2XOQYYG5/2fY@pendragon.ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf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HNCeTkG7+qCDlSaBPclcPGYrTwCt0YWPU2TgGgJrVhYT20ierN8LUvj\n\t6qOPTd+Uk7NFzL65qkh80ZKNBFddx1AabQpSVQKbdcLb8OFs85kuSvFdgqZwgxA1vl4TFhNz\n\tPZ79NAmXLackAx3sOVFhk4WQaKRshCB7cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp\n\tECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx\n\tS0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j\n\tsbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8\n\tpQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc\n\tMW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU\n\tAfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<fba45ad3-3c84-3e37-fceb-7a8335eb95fc@ideasonboard.com>","Date":"Tue, 13 Apr 2021 21:40:39 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<YHYA2XOQYYG5/2fY@pendragon.ideasonboard.com>","Content-Language":"en-GB","Subject":"Re: [libcamera-devel] [PATCH/RFC] libcamera: bound_method: Please\n\tgcc undefined behaviour sanitizer","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Reply-To":"kieran.bingham@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]