[{"id":16834,"web_url":"https://patchwork.libcamera.org/comment/16834/","msgid":"<YJVmxoGoP7HuCtLq@pendragon.ideasonboard.com>","date":"2021-05-07T16:11:50","subject":"Re: [libcamera-devel] [PATCH] libcamera: controls: Remove merge\n\tassertion","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Fri, May 07, 2021 at 01:44:44PM +0100, Kieran Bingham wrote:\n> The ControlList merge operation is protected with an ASSERT to guarantee\n> that the two lists are compatible.\n> \n> Unfortunately this assertion fails when we run IPAs in an isolated case\n> as while the lists are compatible, the isolated IPA has a unique\n> instance of the id map. This breaks the pointer comparison, and the\n> assertion fails with a false positive.\n\nPaul, is this caused by the deserializer using a deserialized idmap\ninstead of a cached pointer to an idmap previously serialized ?\n\n> Remove the assertion, leaving only a todo in it's place as this breaks\n> active users of the library.\n> \n> Bugzilla: https://bugs.libcamera.org/show_bug.cgi?id=31\n\nHow about \"Bug:\" to not make it depend on any particular tool ?\n\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/controls.cpp | 12 +++++++++++-\n>  1 file changed, 11 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\n> index b763148d4391..5aef4e7145bd 100644\n> --- a/src/libcamera/controls.cpp\n> +++ b/src/libcamera/controls.cpp\n> @@ -890,7 +890,17 @@ ControlList::ControlList(const ControlInfoMap &infoMap, ControlValidator *valida\n>   */\n>  void ControlList::merge(const ControlList &source)\n>  {\n> -\tASSERT(idmap_ == source.idmap_);\n> +\t/**\n> +\t * \\todo: ASSERT that the current and source ControlList are derived\n> +\t * from a compatible ControlIdMap, to prevent undefined behaviour due to\n> +\t * id collisions.\n> +\t *\n> +\t * This can not currently be a direct pointer comparison due to the\n> +\t * duplication of the ControlIdMaps in the isolated IPA use cases.\n> +\t * Furthermore, manually checking each entry of the id map is identical\n> +\t * is expensive.\n> +\t * See https://bugs.libcamera.org/show_bug.cgi?id=31 for further details\n> +\t */\n>  \n>  \tfor (const auto &ctrl : source) {\n>  \t\tif (contains(ctrl.first)) {","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 C45D8BF831\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  7 May 2021 16:11:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4CDFA602BF;\n\tFri,  7 May 2021 18:11:58 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CED65602BE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  7 May 2021 18:11:56 +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 388EC2CF;\n\tFri,  7 May 2021 18:11:56 +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=\"AcTw4fgv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1620403916;\n\tbh=TCVn27zaxWf6HQd/fBedDN+WkxxXiXiXwfnnFf4SGvo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AcTw4fgvWUSRO8muoCJZ/1TXYc8ly3zUAs3NWUlJ0E/QI5RVqUBkdFXDdwlHeFaZV\n\tSdHjEu3DQFsXEfQ2w+E2oGPopSN4aOl4CsH8ksz/5RYLotnuotpkPCQ2zEZv/ROaka\n\tDaGAZ5IQunOZVcJNoJWgDF2+xKN7h6ilQuohPfPs=","Date":"Fri, 7 May 2021 19:11:50 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YJVmxoGoP7HuCtLq@pendragon.ideasonboard.com>","References":"<20210507124444.1089347-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210507124444.1089347-1-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: controls: Remove merge\n\tassertion","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 <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":16845,"web_url":"https://patchwork.libcamera.org/comment/16845/","msgid":"<20210508063257.m6kkknqiqcti3kic@uno.localdomain>","date":"2021-05-08T06:32:57","subject":"Re: [libcamera-devel] [PATCH] libcamera: controls: Remove merge\n\tassertion","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Kieran,\n   thanks for handling this and sorry for introducing it in first\n   place\n\nOn Fri, May 07, 2021 at 07:11:50PM +0300, Laurent Pinchart wrote:\n> Hi Kieran,\n>\n> Thank you for the patch.\n>\n> On Fri, May 07, 2021 at 01:44:44PM +0100, Kieran Bingham wrote:\n> > The ControlList merge operation is protected with an ASSERT to guarantee\n> > that the two lists are compatible.\n> >\n> > Unfortunately this assertion fails when we run IPAs in an isolated case\n> > as while the lists are compatible, the isolated IPA has a unique\n> > instance of the id map. This breaks the pointer comparison, and the\n> > assertion fails with a false positive.\n>\n> Paul, is this caused by the deserializer using a deserialized idmap\n> instead of a cached pointer to an idmap previously serialized ?\n>\n> > Remove the assertion, leaving only a todo in it's place as this breaks\n> > active users of the library.\n> >\n> > Bugzilla: https://bugs.libcamera.org/show_bug.cgi?id=31\n>\n> How about \"Bug:\" to not make it depend on any particular tool ?\n>\n> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nWith either Bug: or Bugzilla: (with a slight preference for the first)\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n\n\n>\n> > ---\n> >  src/libcamera/controls.cpp | 12 +++++++++++-\n> >  1 file changed, 11 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\n> > index b763148d4391..5aef4e7145bd 100644\n> > --- a/src/libcamera/controls.cpp\n> > +++ b/src/libcamera/controls.cpp\n> > @@ -890,7 +890,17 @@ ControlList::ControlList(const ControlInfoMap &infoMap, ControlValidator *valida\n> >   */\n> >  void ControlList::merge(const ControlList &source)\n> >  {\n> > -\tASSERT(idmap_ == source.idmap_);\n> > +\t/**\n> > +\t * \\todo: ASSERT that the current and source ControlList are derived\n> > +\t * from a compatible ControlIdMap, to prevent undefined behaviour due to\n> > +\t * id collisions.\n> > +\t *\n> > +\t * This can not currently be a direct pointer comparison due to the\n> > +\t * duplication of the ControlIdMaps in the isolated IPA use cases.\n> > +\t * Furthermore, manually checking each entry of the id map is identical\n> > +\t * is expensive.\n> > +\t * See https://bugs.libcamera.org/show_bug.cgi?id=31 for further details\n> > +\t */\n> >\n> >  \tfor (const auto &ctrl : source) {\n> >  \t\tif (contains(ctrl.first)) {\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 937B6BF829\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  8 May 2021 06:32:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 07D5568919;\n\tSat,  8 May 2021 08:32:15 +0200 (CEST)","from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 42D84602B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  8 May 2021 08:32:14 +0200 (CEST)","from uno.localdomain (host-79-53-131-195.retail.telecomitalia.it\n\t[79.53.131.195]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 310AF20009;\n\tSat,  8 May 2021 06:32:12 +0000 (UTC)"],"X-Originating-IP":"79.53.131.195","Date":"Sat, 8 May 2021 08:32:57 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210508063257.m6kkknqiqcti3kic@uno.localdomain>","References":"<20210507124444.1089347-1-kieran.bingham@ideasonboard.com>\n\t<YJVmxoGoP7HuCtLq@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<YJVmxoGoP7HuCtLq@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: controls: Remove merge\n\tassertion","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 <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":16848,"web_url":"https://patchwork.libcamera.org/comment/16848/","msgid":"<423eb29d-cb0b-b711-c03b-fb5ed443c6a5@ideasonboard.com>","date":"2021-05-09T11:02:46","subject":"Re: [libcamera-devel] [PATCH] libcamera: controls: Remove merge\n\tassertion","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn 08/05/2021 07:32, Jacopo Mondi wrote:\n> Hi Kieran,\n>    thanks for handling this and sorry for introducing it in first\n>    place\n\nNo problem,\n\n> On Fri, May 07, 2021 at 07:11:50PM +0300, Laurent Pinchart wrote:\n>> Hi Kieran,\n>>\n>> Thank you for the patch.\n>>\n>> On Fri, May 07, 2021 at 01:44:44PM +0100, Kieran Bingham wrote:\n>>> The ControlList merge operation is protected with an ASSERT to guarantee\n>>> that the two lists are compatible.\n>>>\n>>> Unfortunately this assertion fails when we run IPAs in an isolated case\n>>> as while the lists are compatible, the isolated IPA has a unique\n>>> instance of the id map. This breaks the pointer comparison, and the\n>>> assertion fails with a false positive.\n>>\n>> Paul, is this caused by the deserializer using a deserialized idmap\n>> instead of a cached pointer to an idmap previously serialized ?\n>>\n>>> Remove the assertion, leaving only a todo in it's place as this breaks\n>>> active users of the library.\n>>>\n>>> Bugzilla: https://bugs.libcamera.org/show_bug.cgi?id=31\n>>\n>> How about \"Bug:\" to not make it depend on any particular tool ?\n>>\n>>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>>\n>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> With either Bug: or Bugzilla: (with a slight preference for the first)\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nBut I'm afraid I had already merged it...\n\n--\nKieran\n\n> \n> Thanks\n>    j\n> \n> \n>>\n>>> ---\n>>>  src/libcamera/controls.cpp | 12 +++++++++++-\n>>>  1 file changed, 11 insertions(+), 1 deletion(-)\n>>>\n>>> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\n>>> index b763148d4391..5aef4e7145bd 100644\n>>> --- a/src/libcamera/controls.cpp\n>>> +++ b/src/libcamera/controls.cpp\n>>> @@ -890,7 +890,17 @@ ControlList::ControlList(const ControlInfoMap &infoMap, ControlValidator *valida\n>>>   */\n>>>  void ControlList::merge(const ControlList &source)\n>>>  {\n>>> -\tASSERT(idmap_ == source.idmap_);\n>>> +\t/**\n>>> +\t * \\todo: ASSERT that the current and source ControlList are derived\n>>> +\t * from a compatible ControlIdMap, to prevent undefined behaviour due to\n>>> +\t * id collisions.\n>>> +\t *\n>>> +\t * This can not currently be a direct pointer comparison due to the\n>>> +\t * duplication of the ControlIdMaps in the isolated IPA use cases.\n>>> +\t * Furthermore, manually checking each entry of the id map is identical\n>>> +\t * is expensive.\n>>> +\t * See https://bugs.libcamera.org/show_bug.cgi?id=31 for further details\n>>> +\t */\n>>>\n>>>  \tfor (const auto &ctrl : source) {\n>>>  \t\tif (contains(ctrl.first)) {\n>>\n>> --\n>> Regards,\n>>\n>> Laurent Pinchart\n>> _______________________________________________\n>> libcamera-devel mailing list\n>> libcamera-devel@lists.libcamera.org\n>> https://lists.libcamera.org/listinfo/libcamera-devel","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 0BA9FBF829\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  9 May 2021 11:02:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1661E68918;\n\tSun,  9 May 2021 13:02:51 +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 47C0E602B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  9 May 2021 13:02:49 +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 8FA914A0;\n\tSun,  9 May 2021 13:02:48 +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=\"LhYILBpU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1620558168;\n\tbh=7DmWisC7jq9+yAfCvE9iaZlwD+mawPJuZBAqxXcpgvI=;\n\th=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=LhYILBpU4Cl7ytpccJU0P0NSau2ijxt/uxpRbyQrG/MtIAqLWeylimSO+CP6/uSew\n\tsf5A2coOYo4CEMoS1MHUE0rCamLt+vVSbTSx6m7FApU/J4+lSzj9DA1+cQ8yzlJuCI\n\tc2UFQvxb8IPK6ui7h/Nt5Q8Do/zoVYe5gYqBSyro=","To":"Jacopo Mondi <jacopo@jmondi.org>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20210507124444.1089347-1-kieran.bingham@ideasonboard.com>\n\t<YJVmxoGoP7HuCtLq@pendragon.ideasonboard.com>\n\t<20210508063257.m6kkknqiqcti3kic@uno.localdomain>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Organization":"Ideas on Board","Message-ID":"<423eb29d-cb0b-b711-c03b-fb5ed443c6a5@ideasonboard.com>","Date":"Sun, 9 May 2021 12:02:46 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.7.1","MIME-Version":"1.0","In-Reply-To":"<20210508063257.m6kkknqiqcti3kic@uno.localdomain>","Content-Language":"en-GB","Subject":"Re: [libcamera-devel] [PATCH] libcamera: controls: Remove merge\n\tassertion","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 <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>"}}]