Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using DD function raises a SIGSEGV #87

Open
demanuel opened this issue Aug 31, 2022 · 3 comments
Open

Using DD function raises a SIGSEGV #87

demanuel opened this issue Aug 31, 2022 · 3 comments

Comments

@demanuel
Copy link

Using dd on a LibXML::Document raises a SIGSEGV

Follow up of:
rakudo/rakudo#5052

Copying jonathanstowe analysis:

Trimming it somewhat to:

use LibXML;
use LibXML::Document;


sub MAIN(){
    my LibXML::Document $doc .=  parse: :string('<doc />');
    dd $doc;

}

Gives a back trace:

Thread 1 "rakudo-m" received signal SIGSEGV, Segmentation fault.
0x00007ffff788ec2f in get_attribute () from //usr/local/lib/libmoar.so
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.35-15.fc36.x86_64 libxml2-devel-2.9.14-1.fc36.x86_64 xz-libs-5.2.5-9.fc36.x86_64 zlib-1.2.11-32.fc36.x86_64
(gdb) bt full
#0 0x00007ffff788ec2f in get_attribute () from //usr/local/lib/libmoar.so
No symbol table info available.
#1 0x00007ffff7814494 in MVM_interp_run () from //usr/local/lib/libmoar.so
No symbol table info available.
#2 0x00000000004015ef in main ()
No symbol table info available.

It would appear that the segfault is from trying to obtain the value of an attribute of the LibXML::Document object (it also will happen with say $doc.raku,) which would suggest that some otherwise unused attribute of the CStruct of LibXML::Document is defined with the incorrect size.

So it's likely that this is a problem with LibXML rather than rakudo.

@dwarring
Copy link
Contributor

dwarring commented Aug 31, 2022

Works for me on Rakudo blead 2022.07-3-g9bc1beed7.

Update: Seeing some core dumps on repeated runs, may be flapping.

@dwarring
Copy link
Contributor

As an extra check. both the following C and Raku code agree on an overall size of 176 for xmlDoc:

#include <libxml/tree.h>

int main(void) {
    printf("%ld\n", sizeof(xmlDoc));  # 176
}
use LibXML;
use LibXML::Document;
use NativeCall;

sub MAIN(){
    my LibXML::Document $doc .=  parse: :string('<doc />');
    say nativesizeof($doc.raw); # 176
    dd $doc;
}

@dwarring
Copy link
Contributor

dwarring commented Feb 25, 2023

the raku method has been aliased in LibXML: 0.9..10 to work around [this problem in Spreadsheet::XLXS. The above example now completed with:

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<doc/>\n"

A work-around rather than a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants