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

Segfault when extracting #3

Closed
jnthn opened this issue Jan 10, 2017 · 5 comments
Closed

Segfault when extracting #3

jnthn opened this issue Jan 10, 2017 · 5 comments

Comments

@jnthn
Copy link
Contributor

jnthn commented Jan 10, 2017

I just got a segfault when using this library to extract files. It's a simple use, on a .tar.gz file:

            given await($tarball-location) {
                my Archive::Libarchive $archive .= new(
                    operation => LibarchiveExtract,        
                    file => $_
                );
                $archive.extract;
                $archive.close;
                unlink $_;
            }

Running it under perl6-valgrind-m I see that it seems to be due to mis-use of libarchive somehow; it crashes when calling archive_entry_free:

==4199== Invalid write of size 8
==4199==    at 0x22C10164: archive_wstring_free (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x22C13A4C: archive_mstring_clean (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x22BD4BD8: archive_entry_clear (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x22BD4C98: archive_entry_free (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x50670DD: ??? (in /home/jnthn/dev/MoarVM/install/lib/libmoar.so)
==4199==    by 0x16125B8F: ???
==4199==    by 0x5067018: dc_callvm_call_x64 (in /home/jnthn/dev/MoarVM/install/lib/libmoar.so)
==4199==    by 0x22BD4C8F: ??? (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x273148BF: ???
==4199==  Address 0xc56ac20 is 256 bytes inside a block of size 1,072 free'd
==4199==    at 0x4C2EDEB: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4199==    by 0x22BDE1CC: ??? (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x50670DD: ??? (in /home/jnthn/dev/MoarVM/install/lib/libmoar.so)
==4199==    by 0x16125B8F: ???
==4199==    by 0x5067018: dc_callvm_call_x64 (in /home/jnthn/dev/MoarVM/install/lib/libmoar.so)
==4199==    by 0x22C14A6F: ??? (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x1034EC4F: ???
==4199==  Block was alloc'd at
==4199==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4199==    by 0x22BD31D2: archive_entry_new2 (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x22BDD608: archive_read_new (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x50670DD: ??? (in /home/jnthn/dev/MoarVM/install/lib/libmoar.so)
==4199==    by 0x16125B8F: ???
==4199==    by 0x5067018: dc_callvm_call_x64 (in /home/jnthn/dev/MoarVM/install/lib/libmoar.so)
==4199==    by 0x22BDD5CF: ??? (in /usr/lib/x86_64-linux-gnu/libarchive.so.13.1.2)
==4199==    by 0x2640D55F: ???
@frithnanth
Copy link
Owner

frithnanth commented Jan 10, 2017 via email

@jnthn
Copy link
Contributor Author

jnthn commented Jan 10, 2017

Thanks for the fast response. Unfortunately this doesn't seem to do it; I still get the SEGV and the output under Valgrind looks the same. (I changed the use statement in my code to have :ver<0.0.3> to make sure I really was testing the latest version.)

@frithnanth
Copy link
Owner

frithnanth commented Jan 10, 2017 via email

@frithnanth
Copy link
Owner

I think I have found a probable cause for the segfault: I need to free the Entry object only if the operation is 'write', not on 'read' and 'extract'.
I released v.0.0.4, let me know if it fixes the Segfault.

@frithnanth frithnanth reopened this Jan 11, 2017
@jnthn
Copy link
Contributor Author

jnthn commented Jan 11, 2017

Yes, that fixes it; no segfault and it works correctly. Furthermore, valgrind is silent now, so looks like there are no errors. Many thanks! :-)

@jnthn jnthn closed this as completed Jan 11, 2017
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