After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791691 - libxml2-2.9.7 Python 3 binding: non-UTF-8 string => segfault
libxml2-2.9.7 Python 3 binding: non-UTF-8 string => segfault
Status: RESOLVED DUPLICATE of bug 789714
Product: libxml2
Classification: Platform
Component: python
git master
Other Linux
: Normal major
: ---
Assigned To: Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2017-12-17 01:41 UTC by A. Wilcox (awilfox)
Modified: 2019-11-05 21:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch that fixes this NULL dereference (1.24 KB, patch)
2017-12-17 01:41 UTC, A. Wilcox (awilfox)
none Details | Review

Description A. Wilcox (awilfox) 2017-12-17 01:41:07 UTC
Created attachment 365632 [details] [review]
Patch that fixes this NULL dereference

If an XML error occurs in a file that is not encoded in UTF-8 (the failing source example here was itstool generating the Czech translation of Gnumeric's documentation), PyUnicode_FromString can return NULL.

Since message is passed as argument 1 to the error callback when set, the Python interpreter will crash trying to handle the argument list if this happens.

Attached is a patch that checks for message being NULL and sets it to Py_None like libxml_charPtrConstWrap would if str was NULL.

This is completely unrelated to bug 789813, but was found on Adélie Linux, a derivative of Alpine.

(gdb) bt
  • #0 _PyEval_EvalCodeWithName
    at Python/ceval.c line 3947
  • #1 PyEval_EvalCodeEx
    at Python/ceval.c line 4174
  • #2 function_call
    at Objects/funcobject.c line 604
  • #3 PyObject_Call
    at Objects/abstract.c line 2261
  • #4 PyEval_CallObjectWithKeywords
    at Python/ceval.c line 4744
  • #5 libxml_xmlErrorFuncHandler
    at libxml.c line 1644
  • #6 xmlParserPrintFileContextInternal
    at error.c line 208
  • #7 xmlReportError
    at error.c line 406
  • #8 __xmlRaiseError
    at error.c line 633
  • #9 xmlFatalErrMsgStrIntStr
    at parser.c line 717
  • #10 xmlParseEndTag2
    at parser.c line 9676
  • #11 xmlParseElement__internal_alias
    at parser.c line 10044
  • #12 xmlParseContent__internal_alias
    at parser.c line 9853
  • #13 xmlParseElement__internal_alias
    at parser.c line 10021
  • #14 xmlParseContent__internal_alias
    at parser.c line 9853
  • #15 xmlParseElement__internal_alias
    at parser.c line 10021
  • #16 xmlParseDocument__internal_alias
    at parser.c line 10718
  • #17 libxml_xmlParseDocument
    at libxml2-py.c line 4958
  • #18 _PyCFunction_FastCallDict
    at Objects/methodobject.c line 234
  • #19 _PyCFunction_FastCallKeywords
    at Objects/methodobject.c line 294
  • #20 call_function
    at Python/ceval.c line 4824
  • #21 _PyEval_EvalFrameDefault
    at Python/ceval.c line 3322
  • #22 _PyFunction_FastCall
    at Python/ceval.c line 4906
  • #23 fast_function
    at Python/ceval.c line 4948
  • #24 call_function
    at Python/ceval.c line 4845
  • #25 _PyEval_EvalFrameDefault
    at Python/ceval.c line 3322
  • #26 _PyEval_EvalCodeWithName
    at Python/ceval.c line 4153
  • #27 fast_function
    at Python/ceval.c line 4965
  • #28 call_function
    at Python/ceval.c line 4845
  • #29 _PyEval_EvalFrameDefault
    at Python/ceval.c line 3338
  • #30 _PyEval_EvalCodeWithName
    at Python/ceval.c line 4153
  • #31 fast_function
    at Python/ceval.c line 4965
  • #32 call_function
    at Python/ceval.c line 4845
  • #33 _PyEval_EvalFrameDefault
    at Python/ceval.c line 3338
  • #34 _PyEval_EvalCodeWithName
    at Python/ceval.c line 4153
  • #35 fast_function
    at Python/ceval.c line 4965
  • #36 call_function
    at Python/ceval.c line 4845
  • #37 _PyEval_EvalFrameDefault
    at Python/ceval.c line 3338
  • #38 _PyEval_EvalCodeWithName
    at Python/ceval.c line 4153
  • #39 fast_function
    at Python/ceval.c line 4965
  • #40 call_function
    at Python/ceval.c line 4845
  • #41 _PyEval_EvalFrameDefault
    at Python/ceval.c line 3338
  • #42 _PyEval_EvalCodeWithName
    at Python/ceval.c line 4153
  • #43 fast_function
    at Python/ceval.c line 4965
  • #44 call_function
    at Python/ceval.c line 4845
  • #45 _PyEval_EvalFrameDefault
    at Python/ceval.c line 3338
  • #46 _PyEval_EvalCodeWithName
    at Python/ceval.c line 4153
  • #47 fast_function
    at Python/ceval.c line 4965
  • #48 call_function
    at Python/ceval.c line 4845
  • #49 _PyEval_EvalFrameDefault
    at Python/ceval.c line 3338
  • #50 _PyEval_EvalCodeWithName
    at Python/ceval.c line 4153
  • #51 fast_function
    at Python/ceval.c line 4965
  • #52 call_function
    at Python/ceval.c line 4845
  • #53 _PyEval_EvalFrameDefault
    at Python/ceval.c line 3338
  • #54 _PyEval_EvalCodeWithName
    at Python/ceval.c line 4153
  • #55 PyEval_EvalCodeEx
    at Python/ceval.c line 4174
  • #56 PyEval_EvalCode
    at Python/ceval.c line 730
  • #57 run_mod
    at Python/pythonrun.c line 980
  • #58 PyRun_FileExFlags
    at Python/pythonrun.c line 933
  • #59 PyRun_SimpleFileExFlags
    at Python/pythonrun.c line 396
  • #60 PyRun_AnyFileExFlags
    at Python/pythonrun.c line 80
  • #61 run_file
    at Modules/main.c line 338
  • #62 Py_Main
    at Modules/main.c line 809
  • #63 main
    at ./Programs/python.c line 69

Comment 1 Nick Wellnhofer 2019-11-05 21:02:36 UTC

*** This bug has been marked as a duplicate of bug 789714 ***