Bug 1380268
Summary: | [abrt] xmlFindCharEncodingHandler() not thread safe | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Krzysztof Troska <elleander86> | ||||||||||||||||||||||||||||||
Component: | libxml2 | Assignee: | Daniel Veillard <veillard> | ||||||||||||||||||||||||||||||
Status: | CLOSED EOL | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||||||||||||||||||||||||||||
Severity: | unspecified | Docs Contact: | |||||||||||||||||||||||||||||||
Priority: | unspecified | ||||||||||||||||||||||||||||||||
Version: | 26 | CC: | athmanem, c.david86, david.cussans, ezwen-redhatbugzilla, mbarnes, mcrha, ole.schoenburg, sbaszczyj, stefano.manocchio, veillard | ||||||||||||||||||||||||||||||
Target Milestone: | --- | ||||||||||||||||||||||||||||||||
Target Release: | --- | ||||||||||||||||||||||||||||||||
Hardware: | x86_64 | ||||||||||||||||||||||||||||||||
OS: | Unspecified | ||||||||||||||||||||||||||||||||
URL: | https://retrace.fedoraproject.org/faf/reports/bthash/532f42fcd9d3068c35573d130dfa6b3373b5ee92 | ||||||||||||||||||||||||||||||||
Whiteboard: | abrt_hash:4a5b2d7ca66009ce69fa02ffff18bbff3dc2b4bc;VARIANT_ID=workstation; | ||||||||||||||||||||||||||||||||
Fixed In Version: | Doc Type: | If docs needed, set a value | |||||||||||||||||||||||||||||||
Doc Text: | Story Points: | --- | |||||||||||||||||||||||||||||||
Clone Of: | Environment: | ||||||||||||||||||||||||||||||||
Last Closed: | 2018-05-29 11:40:11 UTC | Type: | --- | ||||||||||||||||||||||||||||||
Regression: | --- | Mount Type: | --- | ||||||||||||||||||||||||||||||
Documentation: | --- | CRM: | |||||||||||||||||||||||||||||||
Verified Versions: | Category: | --- | |||||||||||||||||||||||||||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||||||||||||||||||||||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||||||||||||||||||||||||||
Embargoed: | |||||||||||||||||||||||||||||||||
Attachments: |
|
Description
Krzysztof Troska
2016-09-29 07:10:54 UTC
Created attachment 1205832 [details]
File: backtrace
Created attachment 1205833 [details]
File: cgroup
Created attachment 1205834 [details]
File: core_backtrace
Created attachment 1205835 [details]
File: dso_list
Created attachment 1205836 [details]
File: environ
Created attachment 1205837 [details]
File: exploitable
Created attachment 1205838 [details]
File: limits
Created attachment 1205839 [details]
File: maps
Created attachment 1205840 [details]
File: mountinfo
Created attachment 1205841 [details]
File: namespaces
Created attachment 1205842 [details]
File: open_fds
Created attachment 1205843 [details]
File: proc_pid_status
Created attachment 1205844 [details]
File: var_log_messages
Thanks for a bug report. I'm wondering whether this is caused by the same issue as your bug #1380266, only in an address book factory. It's possible, because this particular code is shared between the processes. *** Bug 1412304 has been marked as a duplicate of this bug. *** *** Bug 1449551 has been marked as a duplicate of this bug. *** I think I finally see the cause of the crash. The backtrace has two threads inside xmlFindCharEncodingHandler() at the same line, where one of them crashed. I guess that the function had been called at the same time in both threads for the first time, which means the 'handlers' had been NULL, thus xmlInitCharEncodingHandlers() had been called. Thread interleaving could cause re-initialization of the global 'handlers' variable or anything like that. I think the best option would be to add thread-safety guards around access to global memory in libxml2, because library users cannot guard each libxml2 call themself, especially when the final application uses other libraries, which also use libxml2 API. The libxml2 has xmlMutexPtr already, eventually xmlLockLibrary() can be used, thus it might not be a big deal, no? I'm not sure about xmlInitThreads() though, should it be called from the main thread on an application start? The modules like evolution-ews do not have any main(), it is dynamically loaded in several other background processes and basically any other application can load it, when using evolution/-data-server libraries either directly on indirectly, through language bindings. I can add some internal locking around libxml2 calls in evolution-ews/evolution-data-server, eventually call some libxml2 initializers, like xmlInitCharEncodingHandlers() and possibly others, if you can point me to them, but at least xmlInitCharEncodingHandlers() has a comment that even public, it is usually not needed to be called outside of the libxml2. Created attachment 1334075 [details] reproducer (libxml.c) This is a reproducer for the issue. The first line contains a command to compile it, the second contains a command to run it and get useful results, aka it counts how many times the call failed either due to crashing or when the xmlFindCharEncodingHandler() returned two different handlers for the same encoding. Either crashing or returning two different handlers are the same wrong, from my point of view. The program itself just calls xmlFindCharEncodingHandler() in two threads, similarly as the backtrace above. I even tried to call xmlInitGlobals(); in the main(), but it didn't help (I hoped it'll call the xmlInitCharEncodingHandlers() too). I tried several other calls and realized that xmlInitParser() helps with this particular issue. It seems to be the right thing to do, at least with some xmlInit... functions, according to their documentation and the notes about multi-threaded applications. I mean, maybe this bug can be closed as "eds/evo did not use libxml2 properly, even when they both are heavily multi-threaded". I added e_xml_initialize_in_main(), which calls several xmlInit* functions) into evolution-data-server and call it in appropriate main() functions (for 3.27.1+ [1] and 3.26.2+). I also call it in evolution (for 3.27.1+ [2] and 3.26.2+). [1] https://git.gnome.org/browse/evolution-data-server/commit/?id=4ee08887f [2] https://git.gnome.org/browse/evolution/commit/?id=76a6c1f948 This message is a reminder that Fedora 26 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 26. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '26'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 26 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete. Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed. |