Skip to content

XML to_s error #10365

@jkthorne

Description

@jkthorne

I am trying to write XMLs to a file and I am getting this error.

Invalid memory access (signal 11) at address 0x0
[0x10e782916] *Exception::CallStack::print_backtrace:(Int32 | Nil) +118
[0x10e738a0e] __crystal_sigfault_handler +318
[0x7fff203b7d7d] _sigtramp +29
[0x7fff2720f3b4] xmlFindCharEncodingHandler +176
[0x7fff272776aa] xmlNewSaveCtxt +64
[0x7fff27277889] xmlSaveToIO +31
[0x10e8bcaf6] *XML::Node#to_xml<IO::FileDescriptor>:IO::FileDescriptor +358
[0x10e8bc986] *XML::Node#to_s<IO::FileDescriptor>:Nil +6
[0x10e8058a5] *IO::FileDescriptor@IO#<<<XML::Node>:IO::FileDescriptor +37
[0x10e805867] *IO::FileDescriptor@IO#puts<XML::Node>:Nil +39
[0x10e743819] *puts<XML::Node>:Nil +57
[0x10e8f454a] *Braintree::CLI::DisputeCreateCommand::resolve<Braintree::Operations::Dispute::Sandbox::OpenDispute.class, Braintree::CLI>:NoReturn +2378
[0x10e8f3b78] *Braintree::CLI::DisputeCreateCommand::run<Braintree::CLI>:NoReturn +280
[0x10e89be72] *Braintree::CLI#run:(Bool | Nil) +5042
[0x10e89a951] *Braintree::CLI::run:(Bool | Nil) +17
[0x10e723b2f] __crystal_main +1775
[0x10e9062c6] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +6
[0x10e90612c] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +44
[0x10e72f166] main +6

When I try to reduce this bug down it it starts working again. Here are the versions of XML and Crystal but are the most updated versions on homebrew.

$ crystal --version
Crystal 0.36.1 (2021-02-02)

LLVM: 11.0.1
Default target: x86_64-apple-macosx

$ brew info libxml2
libxml2: stable 2.9.10 (bottled), HEAD [keg-only]
GNOME XML library
http://xmlsoft.org/
/usr/local/Cellar/libxml2/2.9.10_2 (280 files, 10.6MB)
...

Here is a branch with the section of code that is raising the error. Also it works when parsed as HTML.

https://github.com/wontruefree/braintree/blob/bug_xml_parse/src/cli/dispute_create_command.cr#L14-L17

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions