"Kees Zeelenberg" <[EMAIL PROTECTED]> schrieb am Freitag, 29. August 2008 um
15:19 +0200:
>
>
>> I downloaded libarchive 2.4.12-1 and tried the simple test program from
>> the archive_write.3 documentation.
>> The program failed with a segment fault in function write_archive_header()
>> in archive_write.c:319.
>> As libarchive-2.5.5 does not contain the call to function strcmp() at that
>> line, I tried to build 2.5.5 directly, but was unable to
>> do so.
>Could you post a small program, preferably the smallest one possible, that
>fails in this way? And also give the exact compilation and linking commands
>that you used.
I'm afraid i can't get it any smaller. The file test.c compiled and linked
with:
gcc -I/c/Programme/GnuWin32/include -o test1.exe test.c
-L/c/Programme/GnuWin32/lib -larchive
I use MSYS instead of cygwin for compiling, hence /c instead of /cygdrive/c for
the -I and -L flags.
It compiles fine, but fails on runtime with a segment fault at the line denoted
with ->. A stacktrace generated
by GDB leads to the source described above:
#include <sys/stat.h>
#include <archive.h>
#include <archive_entry.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
struct mydata
{
const char *name;
int fd;
};
int myopen(struct archive *a, void *client_data)
{
struct mydata *mydata = client_data;
mydata->fd = open(mydata->name, O_WRONLY | O_CREAT, 0644);
if (mydata->fd >= 0)
return (ARCHIVE_OK);
else
return (ARCHIVE_FATAL);
}
ssize_t mywrite(struct archive *a, void *client_data, const void *buff, size_t
n)
{
struct mydata *mydata = client_data;
return (write(mydata->fd, buff, n));
}
int myclose(struct archive *a, void *client_data)
{
struct mydata *mydata = client_data;
if (mydata->fd > 0)
close(mydata->fd);
return (0);
}
void write_archive(const char *outname, const char **filename)
{
struct mydata *mydata = malloc(sizeof(struct mydata));
struct archive *a;
struct archive_entry *entry;
struct stat st;
char buff[8192];
int len;
int fd;
a = archive_write_new();
mydata->name = outname;
archive_write_set_compression_gzip(a);
archive_write_set_format_ustar(a);
archive_write_open(a, mydata, myopen, mywrite, myclose);
while (*filename)
{
stat(*filename, &st);
entry = archive_entry_new();
archive_entry_copy_stat(entry, &st);
archive_entry_set_pathname(entry, *filename);
/*->*/ archive_write_header(a, entry);
fd = open(*filename, O_RDONLY);
len = read(fd, buff, sizeof(buff)); while ( len > 0 ) {
archive_write_data(a, buff, len); len = read(fd, buff,
sizeof(buff)); }
archive_entry_free(entry);
filename++;
}
archive_write_finish(a);
}
int main(int argc, const char **argv)
{
const char *outname;
argv++;
outname = *(argv++);
write_archive(outname, argv);
return 0;
}
>Libarchive-2.4.12-1 should compile as it is, i.e. unpack
>libarchive-2.4.12-1-src.zip, and at a Cygwin bash prompt in the directory
>libarchive-2.4.12, type: "./config.status" (in order to recreate the .deps
>subdirectories) and then: "make"; see also
>http://gnuwin32.sourceforge.net/compile.html
Looks like i got some MSYS issues here. I will install cygwin and try again.
Regards,
Oliver Fladda
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
GnuWin32-Users mailing list
GnuWin32-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnuwin32-users