From 46d544345cbae270da533a737e334880720ceea5 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Tue, 2 Jun 2020 11:15:37 +0900 Subject: libcamera: IPAManager: make IPAManager lifetime explicitly managed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If any ipa_context instances are destroyed after the IPAManager is destroyed, then a segfault will occur, since the modules have been unloaded by the IPAManager and the context function pointers have been freed. Fix this by making the lifetime of the IPAManager explicit, and make the CameraManager construct and deconstruct (automatically, via a unique pointer) the IPAManager. Also update the IPA interface test to do the construction and deconstruction of the IPAManager, as it does not use the CameraManager. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- test/ipa/ipa_interface_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/ipa') diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 2f02af49..153493ba 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -39,11 +39,15 @@ public: ~IPAInterfaceTest() { delete notifier_; + ipa_.reset(); + ipaManager_.reset(); } protected: int init() override { + ipaManager_ = make_unique(); + /* Create a pipeline handler for vimc. */ std::vector &factories = PipelineHandlerFactory::factories(); @@ -161,6 +165,7 @@ private: std::shared_ptr pipe_; std::unique_ptr ipa_; + std::unique_ptr ipaManager_; enum IPAOperationCode trace_; EventNotifier *notifier_; int fd_; -- cgit v1.2.1