GNOME Bugzilla – Bug 695932
Segmentation fault when using | at end of pattern regex.
Last modified: 2021-07-05 13:21:10 UTC
libxml2 issues a segmentation fault when creating xsd pattern regular expression that contains a specific pattern of () parenthesis and | pipes. You will notice I did this on OSX, however I experience the same issue on Ubuntu as well. =text.xsd= <?xml version="1.0" encoding="UTF-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="data"> <xs:complexType> <xs:all> <xs:element name="phone1"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="([0-9]{10})|"></xs:pattern> </xs:restriction> </xs:simpleType> </xs:element> </xs:all> </xs:complexType> </xs:element> </xs:schema> =test.xml= <?xml version="1.0" encoding="utf-8"?> <data> <phone1>2484718566</phone1> </data> =GDB= gdb --args xmllint --noout --schema test.xsd test.xml GNU gdb 6.3.50-20050815 (Apple version gdb-1820) (Sat Jun 16 02:40:11 UTC 2012) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ... done (gdb) run Starting program: /usr/bin/xmllint --noout --schema test.xsd test.xml Reading symbols for shared libraries ++................................ done Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000014 0x00007fff8f082e3e in xmlRegexpExec () (gdb) bt
+ Trace 231648
=Regular expressions that work (Possible work arounds)= ([0-9]{10})|() [0-9]{10}| [0-9]{10}|() =Regular expressions that do not work= ([0-9]{10})| =How it should work= Fail gracefully and let me know I have written a bad regular expression.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.