zeux / pugixml

Light-weight, simple and fast XML parser for C++ with XPath support
http://pugixml.org/
MIT License
4k stars 726 forks source link

Segfault with pugixml 1.13 using clang #539

Closed nekiro closed 1 year ago

nekiro commented 1 year ago

I get segfault pointing to pugi::xml_document::_destroy on macbook 14 m1 pro. Pugixml installed via homebrew. Macos ventura 13.1.

* thread #2, stop reason = EXC_BAD_ACCESS (code=2, address=0x16e78810f)
  * frame #0: 0x0000000101167918 libpugixml.1.dylib`pugi::xml_document::_destroy() + 96
    frame #1: 0x0000000101168668 libpugixml.1.dylib`pugi::xml_document::load_file(char const*, unsigned int, pugi::xml_encoding) + 44
Process 9080 stopped
* thread #2, stop reason = EXC_BAD_ACCESS (code=2, address=0x16e78810f)
    frame #0: 0x0000000101167918 libpugixml.1.dylib`pugi::xml_document::_destroy() + 96
libpugixml.1.dylib`pugi::xml_document::_destroy:
->  0x101167918 <+96>:  ldr    x0, [x8, #0x10]
    0x10116791c <+100>: cbz    x0, 0x101167938           ; <+128>
    0x101167920 <+104>: adrp   x20, 21
    0x101167924 <+108>: ldr    x21, [x0, #0x10]
Target 0: (tfs) stopped.

Code sample can be found here: https://github.com/otland/forgottenserver/blob/master/src/vocation.cpp#L12

zeux commented 1 year ago

This sounds like a configuration issue of some sort, but it works just fine for me on homebrew version of pugixml with an M2 system with this isolated code snippet:

#include <pugixml.hpp>
#include <stdio.h>

int main()
{
        pugi::xml_document doc;
        pugi::xml_parse_result res = doc.load_file("test.xml");
        printf("%s\n", res.description());
}

And this build step:

c++ test.cpp -I/opt/homebrew/include -lpugixml -L/opt/homebrew/lib
nekiro commented 1 year ago

yep, custom findpugixml causes that problem, removed it and reinstalled thru homebrew, appears to go thru without any crashes, thanks