-
Notifications
You must be signed in to change notification settings - Fork 6
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
Comments
My bad: .extract() doesn't have to explicitly .free the entry structure,
since it's already taken care of by the DESTROY submethod in
Archive::Libarchive::Entry.
I pushed the new version.
…On Tue, Jan 10, 2017 at 5:58 PM, Jonathan Worthington < ***@***.***> wrote:
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: ???
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADyA2NpW7wkyWI0dZqll0O6oo_njqdiFks5rQ7i7gaJpZM4Lfpgz>
.
--
Fernando Santagata
|
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 |
I tried this:
my $tarball-location = start { 't/test.tar.gz' };
given await($tarball-location) {
my Archive::Libarchive $archive .= new(
operation => LibarchiveExtract,
file => $_
);
$archive.extract;
$archive.close;
}
and it extracted the files without crashing.
Please send me a minimal test case that crashes, so I can look into it.
…On Tue, Jan 10, 2017 at 6:28 PM, Jonathan Worthington < ***@***.***> wrote:
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.)
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADyA2MS3FpggTvYwWedNF6LXu3RXak6rks5rQ7-_gaJpZM4Lfpgz>
.
--
Fernando Santagata
|
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'. |
Yes, that fixes it; no segfault and it works correctly. Furthermore, valgrind is silent now, so looks like there are no errors. Many thanks! :-) |
I just got a segfault when using this library to extract files. It's a simple use, on a
.tar.gz
file:Running it under
perl6-valgrind-m
I see that it seems to be due to mis-use of libarchive somehow; it crashes when callingarchive_entry_free
:The text was updated successfully, but these errors were encountered: