Skip to content
Snippets Groups Projects
Unverified Commit bbccb6a2 authored by Chris Lalancette's avatar Chris Lalancette Committed by GitHub
Browse files

Fix sros2 tests on Windows Debug. (#317)


From what I can tell, it looks like lxml has a bug
where it doesn't properly track references to objects
via the find() method.  This manifests on Windows debug
as a crash *after* we have stopped using the object, but
I believe that by that point the underlying memory has
already been freed.  Windows Debug in particular is sensitive
to this.

Fix it by doing a deepcopy of the object returned from the
find().  This code isn't performance sensitive, so it shouldn't
be a big deal to do it here, and it fixes the bug in my testing.

Signed-off-by: default avatarChris Lalancette <clalancette@gmail.com>
parent fb226616
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from copy import deepcopy
from lxml import etree
from sros2.policy import load_policy
......@@ -28,7 +30,7 @@ def get_policy_from_tree(name, policy_tree):
if enclave_element is None:
raise RuntimeError(f'unable to find enclave "{name}"')
enclaves_element = etree.Element('enclaves')
enclaves_element.append(enclave_element)
enclaves_element.append(deepcopy(enclave_element))
policy_element = etree.Element('policy')
policy_element.append(enclaves_element)
return policy_element
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment