From 8855ce5a79dc43c7751c419c0f8af37f445ab9d8 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 16 Sep 2014 12:13:42 +0200 Subject: regtools/soc_desc: fix libxml2 misinit The code did not call xmlInitParser() and would call xmlCleanupParser() each time which is doubly wrong because 1) it's not init 2) all init/cleanup must be done from the main thread. To ensure 2), call it from a static ctor. Change-Id: I3d191bf3b8c0cfc51da78157e88c786636fd3ebf Reviewed-on: http://gerrit.rockbox.org/966 Reviewed-by: Amaury Pouly --- utils/regtools/lib/soc_desc.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/utils/regtools/lib/soc_desc.cpp b/utils/regtools/lib/soc_desc.cpp index 1c9eaf7972..3904f6a77e 100644 --- a/utils/regtools/lib/soc_desc.cpp +++ b/utils/regtools/lib/soc_desc.cpp @@ -293,7 +293,6 @@ bool soc_desc_parse_xml(const std::string& filename, soc_t& socs) bool ret = parse_root_elem(root_element, socs); xmlFreeDoc(doc); - xmlCleanupParser(); return ret; } @@ -967,3 +966,20 @@ bool soc_desc_evaluate_formula(const std::string& formula, my_evaluator e(formula, var); return e.parse(result, error); } + +/** WARNING we need to call xmlInitParser() to init libxml2 but it needs to + * called from the main thread, which is a super strong requirement, so do it + * using a static constructor */ +namespace +{ +class xml_parser_init +{ +public: + xml_parser_init() + { + xmlInitParser(); + } +}; + +xml_parser_init __xml_parser_init; +} -- cgit v1.2.3