[{"id":2662,"web_url":"https://patchwork.libcamera.org/comment/2662/","msgid":"<20190916123114.GD4734@pendragon.ideasonboard.com>","date":"2019-09-16T12:31:14","subject":"Re: [libcamera-devel] [PATCH] test: buffer_import: Initialize\n\tmedia_ and video_","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Mon, Sep 16, 2019 at 02:22:38PM +0200, Jacopo Mondi wrote:\n> When the vivid module used to test buffer importing is not loaded, the\n> test correctly bails out, but during the clean up procedure tries to\n> access media_ and video_ fields, which, if not correctly initialized to\n> nullptr might retain random values and cause a segfault.\n\ns/might retain/will contain/\n\n> Fix this by initializing media_ and video_ to nullptr to make sure they\n> get ignored when cleaup() is called before they get initialized.\n\ns/cleaup/cleanup/\n\nTechnically they will now be initialised before cleanup() is called ;-)\n\n\"... to make sure they are properly handled in cleanup().\" ?\n\n> Fixes: e1a5873701a9 (\"test: camera: Add buffer import and mapping test\")\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  test/camera/buffer_import.cpp | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\n> index 9364e3d1bc44..31af8336dc8a 100644\n> --- a/test/camera/buffer_import.cpp\n> +++ b/test/camera/buffer_import.cpp\n> @@ -28,6 +28,11 @@ static constexpr unsigned int CAMERA_BUFFER_COUNT = 4;\n>  class FrameSink\n>  {\n>  public:\n> +\tFrameSink()\n> +\t\t: media_(nullptr), video_(nullptr)\n> +\t{\n> +\t}\n> +\n>  \tint init()\n>  \t{\n>  \t\tint ret;","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 37F7360BE6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Sep 2019 14:31:24 +0200 (CEST)","from pendragon.ideasonboard.com (bl10-204-24.dsl.telepac.pt\n\t[85.243.204.24])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 77539528;\n\tMon, 16 Sep 2019 14:31:23 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1568637083;\n\tbh=tGHoHWvXdzuCcwDzJr+DmPK7GT2gAh5tNeirGozY4Ks=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=rgTYsJqZvutw3VPWx1L0wSm6MWaI19+fYfzlDqZ8r0IoCehLAXtKro/NoJQF7Yz5F\n\tEadq4PeZfC2gUo8cSDovMURK3vrb5K/370uhlm2s4QPERPmlVRpi85lbWC6W6Z+MzY\n\tGfNOtMFOFfiWiQZihCWIMyHe4VzQ7SEpQBpjH3o8=","Date":"Mon, 16 Sep 2019 15:31:14 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190916123114.GD4734@pendragon.ideasonboard.com>","References":"<20190916122238.10095-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190916122238.10095-1-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH] test: buffer_import: Initialize\n\tmedia_ and video_","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Mon, 16 Sep 2019 12:31:24 -0000"}},{"id":2663,"web_url":"https://patchwork.libcamera.org/comment/2663/","msgid":"<20190916123303.GE4734@pendragon.ideasonboard.com>","date":"2019-09-16T12:33:03","subject":"Re: [libcamera-devel] [PATCH] test: buffer_import: Initialize\n\tmedia_ and video_","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Mon, Sep 16, 2019 at 03:31:14PM +0300, Laurent Pinchart wrote:\n> On Mon, Sep 16, 2019 at 02:22:38PM +0200, Jacopo Mondi wrote:\n> > When the vivid module used to test buffer importing is not loaded, the\n> > test correctly bails out, but during the clean up procedure tries to\n> > access media_ and video_ fields, which, if not correctly initialized to\n> > nullptr might retain random values and cause a segfault.\n> \n> s/might retain/will contain/\n> \n> > Fix this by initializing media_ and video_ to nullptr to make sure they\n> > get ignored when cleaup() is called before they get initialized.\n> \n> s/cleaup/cleanup/\n> \n> Technically they will now be initialised before cleanup() is called ;-)\n> \n> \"... to make sure they are properly handled in cleanup().\" ?\n> \n> > Fixes: e1a5873701a9 (\"test: camera: Add buffer import and mapping test\")\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nActually isn't this needed only for video_ ? media_ is a\nstd::shared_ptr, the default constructor should create an empty\nshared_ptr.\n\n> > ---\n> >  test/camera/buffer_import.cpp | 5 +++++\n> >  1 file changed, 5 insertions(+)\n> > \n> > diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\n> > index 9364e3d1bc44..31af8336dc8a 100644\n> > --- a/test/camera/buffer_import.cpp\n> > +++ b/test/camera/buffer_import.cpp\n> > @@ -28,6 +28,11 @@ static constexpr unsigned int CAMERA_BUFFER_COUNT = 4;\n> >  class FrameSink\n> >  {\n> >  public:\n> > +\tFrameSink()\n> > +\t\t: media_(nullptr), video_(nullptr)\n> > +\t{\n> > +\t}\n> > +\n> >  \tint init()\n> >  \t{\n> >  \t\tint ret;\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":"<laurent.pinchart@ideasonboard.com>","Received":["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 F3F7A60BE6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Sep 2019 14:33:12 +0200 (CEST)","from pendragon.ideasonboard.com (bl10-204-24.dsl.telepac.pt\n\t[85.243.204.24])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 34066528;\n\tMon, 16 Sep 2019 14:33:12 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1568637192;\n\tbh=RQwt/EZANlUYWLdElkWsRnxuRuoPr6QG0UPe5DIoNzY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OYi0Xfim8Je/4OTS+SE+4ArNaz9DZXnMcxyiMcAOqUCFDVnL9gZDQ5Mz5nw6PBKsN\n\tN3OVZ/M7hOgq1xEEGbt65swgjd4MdYYZ8g/Phvdgwx0vvJczJUvRmFFUqiBjzOPhkb\n\tHW9cADxGMaGuTy4gpE9UxUnIzybLu7ejULXzDVPk=","Date":"Mon, 16 Sep 2019 15:33:03 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190916123303.GE4734@pendragon.ideasonboard.com>","References":"<20190916122238.10095-1-jacopo@jmondi.org>\n\t<20190916123114.GD4734@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190916123114.GD4734@pendragon.ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH] test: buffer_import: Initialize\n\tmedia_ and video_","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Mon, 16 Sep 2019 12:33:13 -0000"}}]