[{"id":29471,"web_url":"https://patchwork.libcamera.org/comment/29471/","msgid":"<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>","date":"2024-05-09T09:49:41","subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Naush\n\nOn Wed, May 08, 2024 at 09:04:01AM GMT, Naushir Patuck wrote:\n> The shared_mem_object may be used to construct complex classes, so\n> remove the standard layout type restriction.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nThis looks fine to me, but maybe better check on why this was\nintroduced in first place.\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  include/libcamera/internal/shared_mem_object.h | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h\n> index 9b1d939302a8..c9c0482062bd 100644\n> --- a/include/libcamera/internal/shared_mem_object.h\n> +++ b/include/libcamera/internal/shared_mem_object.h\n> @@ -56,7 +56,7 @@ private:\n>  \tSpan<uint8_t> mem_;\n>  };\n>\n> -template<class T, typename = std::enable_if_t<std::is_standard_layout<T>::value>>\n> +template<class T>\n>  class SharedMemObject : public SharedMem\n>  {\n>  public:\n> --\n> 2.34.1\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 4FB23BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 May 2024 09:49:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DAC5963466;\n\tThu,  9 May 2024 11:49:45 +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 495A463461\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 May 2024 11:49:44 +0200 (CEST)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CE906524;\n\tThu,  9 May 2024 11:49:40 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"v6Ut6Ca6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1715248180;\n\tbh=XqNuBu64BAEWuRXQ9kCkUz4ORX5CMaRuKYRI4qmEZKA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=v6Ut6Ca6IajzzGuwqYagLbvU7f3ro3EOAH2mRv5a68huxTGRkA/ypqNeNyieiCcCw\n\t8iriPJ5kUMO9ULeIY520i/3FToHMjwWGopTz3QCFwjhyhNXPnyx6i/ibNTNaWcE5Fg\n\tn+beEw3N64hXSJ+754rlSQ4adSy5Q1T5OcMpjwUU=","Date":"Thu, 9 May 2024 11:49:41 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","Message-ID":"<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>","References":"<20240508080401.14850-1-naush@raspberrypi.com>\n\t<20240508080401.14850-7-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240508080401.14850-7-naush@raspberrypi.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29485,"web_url":"https://patchwork.libcamera.org/comment/29485/","msgid":"<171525328740.1857112.17964003539923628686@ping.linuxembedded.co.uk>","date":"2024-05-09T11:14:47","subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jacopo Mondi (2024-05-09 10:49:41)\n> Hi Naush\n> \n> On Wed, May 08, 2024 at 09:04:01AM GMT, Naushir Patuck wrote:\n> > The shared_mem_object may be used to construct complex classes, so\n> > remove the standard layout type restriction.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> \n> This looks fine to me, but maybe better check on why this was\n> introduced in first place.\n> \n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n> Thanks\n>   j\n> \n> > ---\n> >  include/libcamera/internal/shared_mem_object.h | 2 +-\n> >  1 file changed, 1 insertion(+), 1 deletion(-)\n> >\n> > diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h\n> > index 9b1d939302a8..c9c0482062bd 100644\n> > --- a/include/libcamera/internal/shared_mem_object.h\n> > +++ b/include/libcamera/internal/shared_mem_object.h\n> > @@ -56,7 +56,7 @@ private:\n> >       Span<uint8_t> mem_;\n> >  };\n> >\n> > -template<class T, typename = std::enable_if_t<std::is_standard_layout<T>::value>>\n> > +template<class T>\n\nI think I'm fine with this as long as the CI builds succeed, so we're\nabout to find out ;-)\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> >  class SharedMemObject : public SharedMem\n> >  {\n> >  public:\n> > --\n> > 2.34.1\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 4BE6FC3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 May 2024 11:14:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 821BC63465;\n\tThu,  9 May 2024 13:14:52 +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 91BAA63460\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 May 2024 13:14:50 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0048B904;\n\tThu,  9 May 2024 13:14:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"p+tU1OOe\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1715253287;\n\tbh=CQ1F3xS3b+08o22OQkN4M4ynRA+0rlnOmbzl/1K0pJQ=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=p+tU1OOeBrbeZVF0I4DkpXycdhAEZW7IyrxjseY1DpE2l+0++RntvSErbmc1Psp0Y\n\tx0kT4AkkQVsqy3W+yMRY4d7ZRiJX8C3GIZpCKzUPcijpBZYtoJLguY579pJWHfpKM5\n\t2xTZAtKeKFik4qQnskBCXFA9WdahsYPR8fjMNW6Q=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>","References":"<20240508080401.14850-1-naush@raspberrypi.com>\n\t<20240508080401.14850-7-naush@raspberrypi.com>\n\t<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>","Subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tNaushir Patuck <naush@raspberrypi.com>","Date":"Thu, 09 May 2024 12:14:47 +0100","Message-ID":"<171525328740.1857112.17964003539923628686@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29487,"web_url":"https://patchwork.libcamera.org/comment/29487/","msgid":"<20240509111615.GF14520@pendragon.ideasonboard.com>","date":"2024-05-09T11:16:15","subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, May 09, 2024 at 11:49:41AM +0200, Jacopo Mondi wrote:\n> On Wed, May 08, 2024 at 09:04:01AM GMT, Naushir Patuck wrote:\n> > The shared_mem_object may be used to construct complex classes, so\n> > remove the standard layout type restriction.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> \n> This looks fine to me, but maybe better check on why this was\n> introduced in first place.\n\nIt was added there because sharing objects containing pointers between\ndifferent processes isn't safe. Naush, what object do you need to store\nin shared memory that has a non-standard layout, but is still safe to\nshare ?\n\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n> > ---\n> >  include/libcamera/internal/shared_mem_object.h | 2 +-\n> >  1 file changed, 1 insertion(+), 1 deletion(-)\n> >\n> > diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h\n> > index 9b1d939302a8..c9c0482062bd 100644\n> > --- a/include/libcamera/internal/shared_mem_object.h\n> > +++ b/include/libcamera/internal/shared_mem_object.h\n> > @@ -56,7 +56,7 @@ private:\n> >  \tSpan<uint8_t> mem_;\n> >  };\n> >\n> > -template<class T, typename = std::enable_if_t<std::is_standard_layout<T>::value>>\n> > +template<class T>\n> >  class SharedMemObject : public SharedMem\n> >  {\n> >  public:","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 AD70EC3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 May 2024 11:16:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 529756346B;\n\tThu,  9 May 2024 13:16:25 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7128F63460\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 May 2024 13:16:24 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D76CC904;\n\tThu,  9 May 2024 13:16:20 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"d66ZyoiC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1715253381;\n\tbh=F2n3J6KhVFXOxosN3xrwfQKlKfJv64XC890/e48l+w0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=d66ZyoiC4Je6tupOmLHkkccPnJmYkUnF7rtHiKv+9vH6zVYyjtjU5jOh/RdmpirBP\n\t+0tDW+xMnMlUj/xLAfTxXl2kwpUbS2G7bM6Atl/P27JXTHXduuzzc5KTZ0dgPCbz7L\n\th1GFXvZaWi8Rf3s4kPl7UPML0+HAn8x8MaBGMpPA=","Date":"Thu, 9 May 2024 14:16:15 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","Message-ID":"<20240509111615.GF14520@pendragon.ideasonboard.com>","References":"<20240508080401.14850-1-naush@raspberrypi.com>\n\t<20240508080401.14850-7-naush@raspberrypi.com>\n\t<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29489,"web_url":"https://patchwork.libcamera.org/comment/29489/","msgid":"<171525377694.1857112.11429837573698659405@ping.linuxembedded.co.uk>","date":"2024-05-09T11:22:56","subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-05-09 12:16:15)\n> On Thu, May 09, 2024 at 11:49:41AM +0200, Jacopo Mondi wrote:\n> > On Wed, May 08, 2024 at 09:04:01AM GMT, Naushir Patuck wrote:\n> > > The shared_mem_object may be used to construct complex classes, so\n> > > remove the standard layout type restriction.\n> > >\n> > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > \n> > This looks fine to me, but maybe better check on why this was\n> > introduced in first place.\n> \n> It was added there because sharing objects containing pointers between\n> different processes isn't safe. Naush, what object do you need to store\n> in shared memory that has a non-standard layout, but is still safe to\n> share ?\n\nOh, interesting point. I wonder if that's why we've seen people get\nsegfaults if the RPi IPA runs in isolation (as then these buffers are\nshared, and could potentially contain invalid pointers?)\n\n--\nKieran\n\n\n> \n> > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> > \n> > > ---\n> > >  include/libcamera/internal/shared_mem_object.h | 2 +-\n> > >  1 file changed, 1 insertion(+), 1 deletion(-)\n> > >\n> > > diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h\n> > > index 9b1d939302a8..c9c0482062bd 100644\n> > > --- a/include/libcamera/internal/shared_mem_object.h\n> > > +++ b/include/libcamera/internal/shared_mem_object.h\n> > > @@ -56,7 +56,7 @@ private:\n> > >     Span<uint8_t> mem_;\n> > >  };\n> > >\n> > > -template<class T, typename = std::enable_if_t<std::is_standard_layout<T>::value>>\n> > > +template<class T>\n> > >  class SharedMemObject : public SharedMem\n> > >  {\n> > >  public:\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 B29B4C3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 May 2024 11:23:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D85B463460;\n\tThu,  9 May 2024 13:23:01 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 37D986342D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 May 2024 13:23:00 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 80392904;\n\tThu,  9 May 2024 13:22:56 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZQhYfDsr\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1715253776;\n\tbh=lfAchs00l4y52Sp68udcn3m6RyZoGrhO/oydIOKjmAE=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ZQhYfDsrfyX14d66U5YPLkfFxuc7pf6RfywHitMQtIsFqGWd6DU3wOkKgoCNg4muy\n\tWiOwCT50DydNwmZT27aKfuhu+qrAmnngNQ31U3ID6/RadzUO5daQeTI2mhHpLawkpC\n\tKAc+SCnwN4zARnQpSid+LnO+5FlCVi7vpYAGATA4=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240509111615.GF14520@pendragon.ideasonboard.com>","References":"<20240508080401.14850-1-naush@raspberrypi.com>\n\t<20240508080401.14850-7-naush@raspberrypi.com>\n\t<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>\n\t<20240509111615.GF14520@pendragon.ideasonboard.com>","Subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Date":"Thu, 09 May 2024 12:22:56 +0100","Message-ID":"<171525377694.1857112.11429837573698659405@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29491,"web_url":"https://patchwork.libcamera.org/comment/29491/","msgid":"<20240509113124.GI14520@pendragon.ideasonboard.com>","date":"2024-05-09T11:31:24","subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, May 09, 2024 at 12:22:56PM +0100, Kieran Bingham wrote:\n> Quoting Laurent Pinchart (2024-05-09 12:16:15)\n> > On Thu, May 09, 2024 at 11:49:41AM +0200, Jacopo Mondi wrote:\n> > > On Wed, May 08, 2024 at 09:04:01AM GMT, Naushir Patuck wrote:\n> > > > The shared_mem_object may be used to construct complex classes, so\n> > > > remove the standard layout type restriction.\n> > > >\n> > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > \n> > > This looks fine to me, but maybe better check on why this was\n> > > introduced in first place.\n> > \n> > It was added there because sharing objects containing pointers between\n> > different processes isn't safe. Naush, what object do you need to store\n> > in shared memory that has a non-standard layout, but is still safe to\n> > share ?\n> \n> Oh, interesting point. I wonder if that's why we've seen people get\n> segfaults if the RPi IPA runs in isolation (as then these buffers are\n> shared, and could potentially contain invalid pointers?)\n\nOn Pi4 the only shared buffer I'm aware of contains the LSC table, so\nthat should be fine. I haven't checked Pi5.\n\nThe std::is_standard_layout() check doesn't catch pointers\nunfortunately, but it catches C++ objects that can contain pointers\n(such as containers from the C++ standard library). It may also catch\nobjects that are fine, if that's the case here, we can try to relax the\ncheck.\n\n> > > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> > > \n> > > > ---\n> > > >  include/libcamera/internal/shared_mem_object.h | 2 +-\n> > > >  1 file changed, 1 insertion(+), 1 deletion(-)\n> > > >\n> > > > diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h\n> > > > index 9b1d939302a8..c9c0482062bd 100644\n> > > > --- a/include/libcamera/internal/shared_mem_object.h\n> > > > +++ b/include/libcamera/internal/shared_mem_object.h\n> > > > @@ -56,7 +56,7 @@ private:\n> > > >     Span<uint8_t> mem_;\n> > > >  };\n> > > >\n> > > > -template<class T, typename = std::enable_if_t<std::is_standard_layout<T>::value>>\n> > > > +template<class T>\n> > > >  class SharedMemObject : public SharedMem\n> > > >  {\n> > > >  public:","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 BC71AC3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 May 2024 11:31:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EB0E463433;\n\tThu,  9 May 2024 13:31:35 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 00F926342D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 May 2024 13:31:33 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 19D6E904;\n\tThu,  9 May 2024 13:31:30 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"UV+lpcpM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1715254290;\n\tbh=xIFtEbYSKqVmJWKpWZcRjjn02MeL3BE0p57pP8cOVaU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=UV+lpcpMSyEGQ7Xjm5gCsIvfsJsWjhKgJVguESGt+IlPzwZxZC2sxOL0hZiTvbK08\n\tZ9/DN556YVjU6vgOJMY+zj2g8CN1DJ0jePzJu/OYQZ8Xg8XOxe9yLwc+dCE4mPTBP6\n\tXSscFkYtz7cBRRSdomNRLiDM92rEmS71NIZUJAxU=","Date":"Thu, 9 May 2024 14:31:24 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tNaushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","Message-ID":"<20240509113124.GI14520@pendragon.ideasonboard.com>","References":"<20240508080401.14850-1-naush@raspberrypi.com>\n\t<20240508080401.14850-7-naush@raspberrypi.com>\n\t<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>\n\t<20240509111615.GF14520@pendragon.ideasonboard.com>\n\t<171525377694.1857112.11429837573698659405@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<171525377694.1857112.11429837573698659405@ping.linuxembedded.co.uk>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29497,"web_url":"https://patchwork.libcamera.org/comment/29497/","msgid":"<CAEmqJPp9UwbkOW+RdakbSOdezro4D0MDK0rGU3p_--u20GOyiw@mail.gmail.com>","date":"2024-05-09T11:55:20","subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"On Thu, 9 May 2024 at 12:31, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> On Thu, May 09, 2024 at 12:22:56PM +0100, Kieran Bingham wrote:\n> > Quoting Laurent Pinchart (2024-05-09 12:16:15)\n> > > On Thu, May 09, 2024 at 11:49:41AM +0200, Jacopo Mondi wrote:\n> > > > On Wed, May 08, 2024 at 09:04:01AM GMT, Naushir Patuck wrote:\n> > > > > The shared_mem_object may be used to construct complex classes, so\n> > > > > remove the standard layout type restriction.\n> > > > >\n> > > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > >\n> > > > This looks fine to me, but maybe better check on why this was\n> > > > introduced in first place.\n> > >\n> > > It was added there because sharing objects containing pointers between\n> > > different processes isn't safe. Naush, what object do you need to store\n> > > in shared memory that has a non-standard layout, but is still safe to\n> > > share ?\n> >\n> > Oh, interesting point. I wonder if that's why we've seen people get\n> > segfaults if the RPi IPA runs in isolation (as then these buffers are\n> > shared, and could potentially contain invalid pointers?)\n>\n> On Pi4 the only shared buffer I'm aware of contains the LSC table, so\n> that should be fine. I haven't checked Pi5.\n>\n\nThe Pi 4 LS tables use a dmabuf and FD between the pipeline handler and\nIPA, so that's ok.\n\n>\n> The std::is_standard_layout() check doesn't catch pointers\n> unfortunately, but it catches C++ objects that can contain pointers\n> (such as containers from the C++ standard library). It may also catch\n> objects that are fine, if that's the case here, we can try to relax the\n> check.\n>\n\nEek, this can be nasty.  Frontend is safe, but Backend is not.  We don't\nuse any pointers but have a couple of std::vectors, these can easily be\nremoved.  It does have a few std::map types that are problematic.  We only\never access these maps and vectors from the pipeline handler side, so\nit \"works\", but potentially fragile.  I don't know what to do here...\n\n\n>\n> > > > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> > > >\n> > > > > ---\n> > > > >  include/libcamera/internal/shared_mem_object.h | 2 +-\n> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)\n> > > > >\n> > > > > diff --git a/include/libcamera/internal/shared_mem_object.h\n> b/include/libcamera/internal/shared_mem_object.h\n> > > > > index 9b1d939302a8..c9c0482062bd 100644\n> > > > > --- a/include/libcamera/internal/shared_mem_object.h\n> > > > > +++ b/include/libcamera/internal/shared_mem_object.h\n> > > > > @@ -56,7 +56,7 @@ private:\n> > > > >     Span<uint8_t> mem_;\n> > > > >  };\n> > > > >\n> > > > > -template<class T, typename =\n> std::enable_if_t<std::is_standard_layout<T>::value>>\n> > > > > +template<class T>\n> > > > >  class SharedMemObject : public SharedMem\n> > > > >  {\n> > > > >  public:\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\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 14E5EC3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 May 2024 11:55:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E91106345F;\n\tThu,  9 May 2024 13:55:51 +0200 (CEST)","from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com\n\t[IPv6:2607:f8b0:4864:20::112e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D71C633FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 May 2024 13:55:50 +0200 (CEST)","by mail-yw1-x112e.google.com with SMTP id\n\t00721157ae682-61be4b98766so8393857b3.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 09 May 2024 04:55:50 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"C5Ww+IFH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1715255749; x=1715860549;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=OvaVWA1b9eSLR4wcZhKuf7TKlS0Hd8dymduj+qr8IZ8=;\n\tb=C5Ww+IFHm+XVMpnJOXZWNMR19bIDCyehMrjm67DZXgM3TaN9jISyJ4qELBSB3XVlJC\n\tOWjrMV9VEyrSohzcr3wiHTKOmj5eTHIAMICoYyMz1rHxJ81KLpXYlq6egBugzx+gel+o\n\tBElJUBIwevrXaifR66ZIhhO7g0tr7FYogFAGPGxLd2SDRzIFz+QY51QkJs4C0iJvY+yA\n\t9gWtJlmyLfVIcFHdGozikNy++5kpM0RDk1ucTAwsutlra0VQUxjpSOr2pNK8LjVXCvWb\n\t/7iCrq3TgVAvL9EJp2M04z6XLSiPvmJ3NicNt5u9eKsEu1MXtxP2mf5Kz0ObsfbdR5r1\n\tTxiQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1715255749; x=1715860549;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=OvaVWA1b9eSLR4wcZhKuf7TKlS0Hd8dymduj+qr8IZ8=;\n\tb=Fr63SCJlFGHTPT87gUyjJ3A3iYnX9yWDoj6HcfHcbmN12Ahlyr7PuikIpIXCQPySJa\n\tRsetyIy8y/qKmiB4IOiv8tC41+K18357i7078prPMnJuFXIsgdWJXBuMQjJwheROXjLJ\n\tIE588PiiaRFvJ6GCx/MRV4mP8F0i9+3X38c7h4bDqmWmDfeKNixtlPr6iw6ogmx0E44k\n\tCv+tWROP0YEp0EAdNhWZZPnMXZgGiW2Gmuc6JtFziBAmiUKq5uWGv8pSbEszP7pVeYxL\n\tLFTcAYQX6+RhwrgnYlsVLsqaD7Ym+VsnivCKX1sozTisxFo/oC057VeHDlpqPRhDDD9r\n\tOV9g==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCWBlVEb2O77evBm8qpX4zeHvBiPZXEGhFT83E8dq679JzFhrvaCxSUBLYW25rNf3aRObdIsB4GP99uXYutcPLyh6AovwoI4kLUiiv1WjET/U7OfCA==","X-Gm-Message-State":"AOJu0Yx7UIjbEFJrB1t0oTMkCQr9VYyVBKGc2rMbsHrKaQpfH1wq4JdK\n\tuTIM5D3J3izkMt+gRfi2T2+6lS8CJSIfHd31YWmKbr3qYU5uDEWDNxSqaIj5RiBWYKcG12Zd5rK\n\trVcQXoxWvHJl0sCuR5PffwXpP3GLl/y4TAbQ8ZihwwtZ6vZYd","X-Google-Smtp-Source":"AGHT+IGQ7MBS85dlBo62g58t5AD4UiwgX34Q5EhjvV6a9BE5BZY5f5nuuBmdZ/oH2cH788xBmovLgHGGjE2jnE81LB4=","X-Received":"by 2002:a81:4892:0:b0:61a:dfd6:fd6d with SMTP id\n\t00721157ae682-62085a748dbmr60819947b3.25.1715255749113;\n\tThu, 09 May 2024 04:55:49 -0700 (PDT)","MIME-Version":"1.0","References":"<20240508080401.14850-1-naush@raspberrypi.com>\n\t<20240508080401.14850-7-naush@raspberrypi.com>\n\t<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>\n\t<20240509111615.GF14520@pendragon.ideasonboard.com>\n\t<171525377694.1857112.11429837573698659405@ping.linuxembedded.co.uk>\n\t<20240509113124.GI14520@pendragon.ideasonboard.com>","In-Reply-To":"<20240509113124.GI14520@pendragon.ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Thu, 9 May 2024 12:55:20 +0100","Message-ID":"<CAEmqJPp9UwbkOW+RdakbSOdezro4D0MDK0rGU3p_--u20GOyiw@mail.gmail.com>","Subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>, \n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Content-Type":"multipart/alternative; boundary=\"000000000000a0127006180419c7\"","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29498,"web_url":"https://patchwork.libcamera.org/comment/29498/","msgid":"<20240509122603.GA17123@pendragon.ideasonboard.com>","date":"2024-05-09T12:26:03","subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nOn Thu, May 09, 2024 at 12:55:20PM +0100, Naushir Patuck wrote:\n> On Thu, 9 May 2024 at 12:31, Laurent Pinchart wrote:\n> > On Thu, May 09, 2024 at 12:22:56PM +0100, Kieran Bingham wrote:\n> > > Quoting Laurent Pinchart (2024-05-09 12:16:15)\n> > > > On Thu, May 09, 2024 at 11:49:41AM +0200, Jacopo Mondi wrote:\n> > > > > On Wed, May 08, 2024 at 09:04:01AM GMT, Naushir Patuck wrote:\n> > > > > > The shared_mem_object may be used to construct complex classes, so\n> > > > > > remove the standard layout type restriction.\n> > > > > >\n> > > > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > >\n> > > > > This looks fine to me, but maybe better check on why this was\n> > > > > introduced in first place.\n> > > >\n> > > > It was added there because sharing objects containing pointers between\n> > > > different processes isn't safe. Naush, what object do you need to store\n> > > > in shared memory that has a non-standard layout, but is still safe to\n> > > > share ?\n> > >\n> > > Oh, interesting point. I wonder if that's why we've seen people get\n> > > segfaults if the RPi IPA runs in isolation (as then these buffers are\n> > > shared, and could potentially contain invalid pointers?)\n> >\n> > On Pi4 the only shared buffer I'm aware of contains the LSC table, so\n> > that should be fine. I haven't checked Pi5.\n> \n> The Pi 4 LS tables use a dmabuf and FD between the pipeline handler and\n> IPA, so that's ok.\n\nAh yes, I forgot for a moment it was using dmabuf.\n\n> > The std::is_standard_layout() check doesn't catch pointers\n> > unfortunately, but it catches C++ objects that can contain pointers\n> > (such as containers from the C++ standard library). It may also catch\n> > objects that are fine, if that's the case here, we can try to relax the\n> > check.\n> \n> Eek, this can be nasty.  Frontend is safe, but Backend is not.  We don't\n> use any pointers but have a couple of std::vectors, these can easily be\n> removed.  It does have a few std::map types that are problematic.  We only\n> ever access these maps and vectors from the pipeline handler side, so\n> it \"works\", but potentially fragile.  I don't know what to do here...\n\nCan we discuss this by looking at the problematic code, and the layout\nof the object you want to share between the pipeline handler and IPA\nside ? A short explanation regarding what parts of the data are read and\nwritten on each side will be useful.\n\n> > > > > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> > > > >\n> > > > > > ---\n> > > > > >  include/libcamera/internal/shared_mem_object.h | 2 +-\n> > > > > >  1 file changed, 1 insertion(+), 1 deletion(-)\n> > > > > >\n> > > > > > diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h\n> > > > > > index 9b1d939302a8..c9c0482062bd 100644\n> > > > > > --- a/include/libcamera/internal/shared_mem_object.h\n> > > > > > +++ b/include/libcamera/internal/shared_mem_object.h\n> > > > > > @@ -56,7 +56,7 @@ private:\n> > > > > >     Span<uint8_t> mem_;\n> > > > > >  };\n> > > > > >\n> > > > > > -template<class T, typename = std::enable_if_t<std::is_standard_layout<T>::value>>\n> > > > > > +template<class T>\n> > > > > >  class SharedMemObject : public SharedMem\n> > > > > >  {\n> > > > > >  public:","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 E9218BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 May 2024 12:26:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D4B776345F;\n\tThu,  9 May 2024 14:26:13 +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 61590633FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 May 2024 14:26:12 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 831F9CC8;\n\tThu,  9 May 2024 14:26:08 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"eumHKkFV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1715257568;\n\tbh=9lktKRN+mVl8jN568yh14plU5x7v4mMZskjQSnTxTos=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=eumHKkFVr05ImkADa20VL/AKTbeK4ciI6ktoU2zI0rhGvOcvLr1aEHVcYRfolW2+V\n\tI2VnbTqzdIPT8H8CX24k86Ug91f4JEM6TKwT7zkuKoPjdxbsY+oZzEXTVf36Tx4hUx\n\tAIw0+5sWQDrRaDpOCQHPX9CfITd8PsOtc+TK0XBk=","Date":"Thu, 9 May 2024 15:26:03 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","Message-ID":"<20240509122603.GA17123@pendragon.ideasonboard.com>","References":"<20240508080401.14850-1-naush@raspberrypi.com>\n\t<20240508080401.14850-7-naush@raspberrypi.com>\n\t<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>\n\t<20240509111615.GF14520@pendragon.ideasonboard.com>\n\t<171525377694.1857112.11429837573698659405@ping.linuxembedded.co.uk>\n\t<20240509113124.GI14520@pendragon.ideasonboard.com>\n\t<CAEmqJPp9UwbkOW+RdakbSOdezro4D0MDK0rGU3p_--u20GOyiw@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAEmqJPp9UwbkOW+RdakbSOdezro4D0MDK0rGU3p_--u20GOyiw@mail.gmail.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":29499,"web_url":"https://patchwork.libcamera.org/comment/29499/","msgid":"<CAEmqJPrzea0P2WTWMn8nMJLuaiuVb_2F=u9RQqm9TrCn+ZGqWA@mail.gmail.com>","date":"2024-05-09T13:38:02","subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"On Thu, 9 May 2024 at 13:26, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Naush,\n>\n> On Thu, May 09, 2024 at 12:55:20PM +0100, Naushir Patuck wrote:\n> > On Thu, 9 May 2024 at 12:31, Laurent Pinchart wrote:\n> > > On Thu, May 09, 2024 at 12:22:56PM +0100, Kieran Bingham wrote:\n> > > > Quoting Laurent Pinchart (2024-05-09 12:16:15)\n> > > > > On Thu, May 09, 2024 at 11:49:41AM +0200, Jacopo Mondi wrote:\n> > > > > > On Wed, May 08, 2024 at 09:04:01AM GMT, Naushir Patuck wrote:\n> > > > > > > The shared_mem_object may be used to construct complex classes, so\n> > > > > > > remove the standard layout type restriction.\n> > > > > > >\n> > > > > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > > >\n> > > > > > This looks fine to me, but maybe better check on why this was\n> > > > > > introduced in first place.\n> > > > >\n> > > > > It was added there because sharing objects containing pointers between\n> > > > > different processes isn't safe. Naush, what object do you need to store\n> > > > > in shared memory that has a non-standard layout, but is still safe to\n> > > > > share ?\n> > > >\n> > > > Oh, interesting point. I wonder if that's why we've seen people get\n> > > > segfaults if the RPi IPA runs in isolation (as then these buffers are\n> > > > shared, and could potentially contain invalid pointers?)\n> > >\n> > > On Pi4 the only shared buffer I'm aware of contains the LSC table, so\n> > > that should be fine. I haven't checked Pi5.\n> >\n> > The Pi 4 LS tables use a dmabuf and FD between the pipeline handler and\n> > IPA, so that's ok.\n>\n> Ah yes, I forgot for a moment it was using dmabuf.\n>\n> > > The std::is_standard_layout() check doesn't catch pointers\n> > > unfortunately, but it catches C++ objects that can contain pointers\n> > > (such as containers from the C++ standard library). It may also catch\n> > > objects that are fine, if that's the case here, we can try to relax the\n> > > check.\n> >\n> > Eek, this can be nasty.  Frontend is safe, but Backend is not.  We don't\n> > use any pointers but have a couple of std::vectors, these can easily be\n> > removed.  It does have a few std::map types that are problematic.  We only\n> > ever access these maps and vectors from the pipeline handler side, so\n> > it \"works\", but potentially fragile.  I don't know what to do here...\n>\n> Can we discuss this by looking at the problematic code, and the layout\n> of the object you want to share between the pipeline handler and IPA\n> side ? A short explanation regarding what parts of the data are read and\n> written on each side will be useful.\n\n\nOk, this turned out to be a lot less painful than I expected.  I've\nmanaged to make classes FrontEnd and BackEnd standard layout types by\ngetting rid of a const reference and the std::maps.\n\nWe can remove this patch from the series.  I'll post an update to\nlibpisp with the changes shortly for you to have a look at the needed\nchanges.\n\nNaush\n\n>\n> > > > > > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> > > > > >\n> > > > > > > ---\n> > > > > > >  include/libcamera/internal/shared_mem_object.h | 2 +-\n> > > > > > >  1 file changed, 1 insertion(+), 1 deletion(-)\n> > > > > > >\n> > > > > > > diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h\n> > > > > > > index 9b1d939302a8..c9c0482062bd 100644\n> > > > > > > --- a/include/libcamera/internal/shared_mem_object.h\n> > > > > > > +++ b/include/libcamera/internal/shared_mem_object.h\n> > > > > > > @@ -56,7 +56,7 @@ private:\n> > > > > > >     Span<uint8_t> mem_;\n> > > > > > >  };\n> > > > > > >\n> > > > > > > -template<class T, typename = std::enable_if_t<std::is_standard_layout<T>::value>>\n> > > > > > > +template<class T>\n> > > > > > >  class SharedMemObject : public SharedMem\n> > > > > > >  {\n> > > > > > >  public:\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 2E3AAC3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 May 2024 13:38:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 331096345F;\n\tThu,  9 May 2024 15:38:41 +0200 (CEST)","from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com\n\t[IPv6:2607:f8b0:4864:20::b35])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E06C633FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 May 2024 15:38:39 +0200 (CEST)","by mail-yb1-xb35.google.com with SMTP id\n\t3f1490d57ef6-de45dba157cso795889276.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 09 May 2024 06:38:39 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"fXEF/rmL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1715261918; x=1715866718;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=u1Y+Vz5nINNzm78qBWgp5YukfhbQQZRV2qGcB/tBBK4=;\n\tb=fXEF/rmLmTi0nrWr0m0mOzXBBIYO/NdOfKR6nVJ++/ZW7p3qMNYwFCCoxSIkJ2ugEc\n\t7xHnTGXjvFyOH2IMw0I3dphBP2DP3RrB4LA70+YsLFyMhsvUlS49zj9aSmANCkVku2ik\n\tMnOZmUuXZQpMXSMmptlqF4TjehQ4RX+A1ltHW35DyBGHpk3daPwUUk0DIc8rTgiPX9a9\n\tle08ByAUeGwRoxKtyD7ee0xeYzW/2Wv8RUD0auyebVJZvRLLC3Z+nx0Ghu3X2PSeU54A\n\tdFLYwReMrmIqDHg1RPyoV9PuJgDEVYyKvTVl+Aq+AYH/D7whcU2BHUtuVFbrsAEskT9x\n\tqpxA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1715261918; x=1715866718;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=u1Y+Vz5nINNzm78qBWgp5YukfhbQQZRV2qGcB/tBBK4=;\n\tb=hszHe1AcOeVxpnAmNNp4zCpIw3U+HrO8oBqxBwjzVUVi4Nd6eR+sHaeIzdmS/XOVqM\n\tEgQ7UGnXm+2RRNBSnF0zE5RANfL2SYvUQhie00Y+DMAax6PZluH0b7ZLc8+iCpiD8BPC\n\tU+HVt6Myswilr2wdxGTZ6kWnVxPdc9g/rf0458UoA/Ovc8/Ds9q9PU6CYGOCH6IHkeh8\n\tFSb77dtmDkf54Czohm8LHx0JE/ZSxxJtOqWb4GsXGcjHDp47QoJTJjFgWxBeW52HZpw3\n\tc21/M0W5psRrXDt9T93nrx8qcsil7RdH/aWGs9/6ZbZDdYr8KcchbWvWV7zUKh0isW18\n\t1Qrw==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCVpwU0JTCdEGFYvygfcBP8cIQngPKJw6c33tjedHyX4veX4ZoD6H7DqWC2+p6x+8uvUEK4VsdtrzOM+U0kMxtMWQ1MDgczhrEGdzPmG4GsEnumslA==","X-Gm-Message-State":"AOJu0YwjD8XtWsDwd/b+zm8cGUfF2nWCXF2rg6hs1UbHbu7y+PQv7eqy\n\t6BhLtplQ2YpK2baiEecxr4iaeTEgOBsVbTlw0PIDQoA074KM0XhcIZmFlxLnz1rsgvj3OL5Yy0Q\n\tf0XtIlnt7/TuzEb644erH94OnZ4vCLIspnCH1HTkTACDp0pd6","X-Google-Smtp-Source":"AGHT+IGas+gssC/uYIOzDe9IQKshopPpI2a/qgiWfA+eAzH7zkBJh7diFJsu6r1wbtpGosMkJR+ItQKyq2CSixwGbZY=","X-Received":"by 2002:a25:1087:0:b0:dcf:411f:e78 with SMTP id\n\t3f1490d57ef6-debb9cfd236mr5165207276.25.1715261918107;\n\tThu, 09 May 2024 06:38:38 -0700 (PDT)","MIME-Version":"1.0","References":"<20240508080401.14850-1-naush@raspberrypi.com>\n\t<20240508080401.14850-7-naush@raspberrypi.com>\n\t<ilrqzt2cly7bjg3ow67po3aryciulmd2agj4xurkile5xzkgtb@uh3rjztcls64>\n\t<20240509111615.GF14520@pendragon.ideasonboard.com>\n\t<171525377694.1857112.11429837573698659405@ping.linuxembedded.co.uk>\n\t<20240509113124.GI14520@pendragon.ideasonboard.com>\n\t<CAEmqJPp9UwbkOW+RdakbSOdezro4D0MDK0rGU3p_--u20GOyiw@mail.gmail.com>\n\t<20240509122603.GA17123@pendragon.ideasonboard.com>","In-Reply-To":"<20240509122603.GA17123@pendragon.ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Thu, 9 May 2024 14:38:02 +0100","Message-ID":"<CAEmqJPrzea0P2WTWMn8nMJLuaiuVb_2F=u9RQqm9TrCn+ZGqWA@mail.gmail.com>","Subject":"Re: [PATCH v2 6/6] libcamera: shared_mem_object: Remove\n\tis_standard_layout restriction","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>, \n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]