-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make
DataHandle
type check more robust (#3768)
It seems that the current implementation is prone to symbol hiding. I worked around this by inserting another non-templated layer in the class hierarchy which can do the type check more reliably. The origin of the problem could be `-fvisibility=hidden` being toggled on all of my `ActsPythonBindings` compilation commands. It might be that this is another case where this flag leaks in via CMake from another library. I also did not want to change the visibility of the symbol manually as this would require some macros to be compiler agnostic. Some resources - https://www.qt.io/blog/quality-assurance/one-way-dynamic_cast-across-library-boundaries-can-fail-and-how-to-fix-it - https://developers.redhat.com/articles/2021/10/27/compiler-option-hidden-visibility-and-weak-symbol-walk-bar#
- Loading branch information
Showing
5 changed files
with
69 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// This file is part of the ACTS project. | ||
// | ||
// Copyright (C) 2016 CERN for the benefit of the ACTS project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
#include "ActsExamples/Framework/DataHandle.hpp" | ||
|
||
namespace ActsExamples { | ||
|
||
void WriteDataHandleBase::initialize(const std::string& key) { | ||
if (key.empty()) { | ||
throw std::invalid_argument{"Write handle '" + fullName() + | ||
"' cannot receive empty key"}; | ||
} | ||
m_key = key; | ||
} | ||
|
||
bool WriteDataHandleBase::isCompatible(const DataHandleBase& other) const { | ||
return dynamic_cast<const ReadDataHandleBase*>(&other) != nullptr && | ||
typeInfo() == other.typeInfo(); | ||
} | ||
|
||
void ReadDataHandleBase::initialize(const std::string& key) { | ||
if (key.empty()) { | ||
throw std::invalid_argument{"Read handle '" + fullName() + | ||
"' cannot receive empty key"}; | ||
} | ||
m_key = key; | ||
} | ||
|
||
bool ReadDataHandleBase::isCompatible(const DataHandleBase& other) const { | ||
return dynamic_cast<const WriteDataHandleBase*>(&other) != nullptr && | ||
typeInfo() == other.typeInfo(); | ||
} | ||
|
||
} // namespace ActsExamples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters