View Issue Details

IDProjectCategoryView StatusLast Update
0003033GNUnetfile-sharing servicepublic2013-12-24 20:54
Reporterbratao Assigned ToLRN  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformW32OSWindowsOS Version8.1
Product VersionGit master 
Target Version0.10.0Fixed in Version0.10.0 
Summary0003033: File downloaded get corrupted / TRUNCATE needed in plibc
DescriptionUsing the latest SVN (r29220 ) , I shared a couple of music files, and tried to download them later.
All got randomly corrupted.

I don't really know what extra information should I put here.
TagsNo tags attached.
Attached Files
gnunet-plib_update.patch (5,181 bytes)   
Index: src/fs/fs_download.c
===================================================================
--- src/fs/fs_download.c	(revision 29251)
+++ src/fs/fs_download.c	(working copy)
@@ -541,7 +541,7 @@
     GNUNET_FS_download_make_status_ (&pi, dc);
     if ((NULL != dc->filename) &&
         (0 !=
-         truncate (dc->filename,
+         TRUNCATE (dc->filename,
                    GNUNET_ntohll (dc->uri->data.chk.file_length))))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
                                 dc->filename);
@@ -1103,7 +1103,7 @@
     if (NULL != dc->filename)
     {
       if (0 !=
-          truncate (dc->filename,
+          TRUNCATE (dc->filename,
                     GNUNET_ntohll (dc->uri->data.chk.file_length)))
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
                                   dc->filename);
@@ -1767,7 +1767,7 @@
 	if (NULL != dc->filename)
 	{
 	  if (0 !=
-	      truncate (dc->filename,
+	      TRUNCATE (dc->filename,
 			GNUNET_ntohll (dc->uri->data.chk.file_length)))
 	    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
 				      dc->filename);
Index: src/include/plibc.h
===================================================================
--- src/include/plibc.h	(revision 29251)
+++ src/include/plibc.h	(working copy)
@@ -22,7 +22,7 @@
  * @brief PlibC header
  * @attention This file is usually not installed under Unix,
  *            so ship it with your application
- * @version $Revision$
+ * @version $Revision: 149 $
  */
 
 #ifndef _PLIBC_H_
@@ -115,6 +115,10 @@
   _SC_PAGE_SIZE = 30
 };
 
+#if !defined(EACCESS)
+#  define EACCESS EACCES
+#endif
+
 /* Thanks to the Cygwin project */
 #if !defined(ENOCSI)
 #  define ENOCSI 43	/* No CSI structure available */
@@ -521,9 +525,6 @@
 #if USE_IPV6
 int inet_pton6(const char *src, u_char *dst);
 #endif
-#if !defined(FTRUNCATE_DEFINED)
-int truncate(const char *fname, int distance);
-#endif
 int statfs(const char *path, struct statfs *buf);
 const char *hstrerror(int err);
 int mkstemp(char *tmplate);
@@ -557,8 +558,9 @@
 int _win_creat(const char *path, mode_t mode);
 char *_win_ctime(const time_t *clock);
 char *_win_ctime_r(const time_t *clock, char *buf);
-int _win_fstat(int handle, struct stat *buffer);
+int _win_fstat(int handle, struct _stat *buffer);
 int _win_ftruncate(int fildes, off_t length);
+int _win_truncate(const char *fname, int distance);
 int _win_kill(pid_t pid, int sig);
 int _win_pipe(int *phandles);
 intptr_t _win_mkfifo(const char *path, mode_t mode);
@@ -570,7 +572,7 @@
 void _win_srandom(unsigned int seed);
 int _win_remove(const char *path);
 int _win_rename(const char *oldname, const char *newname);
-int _win_stat(const char *path, struct stat *buffer);
+int _win_stat(const char *path, struct _stat *buffer);
 int _win_stat64(const char *path, struct stat64 *buffer);
 long _win_sysconf(int name);
 int _win_unlink(const char *filename);
@@ -583,7 +585,7 @@
                 unsigned long long offset);
 int _win_msync(void *start, size_t length, int flags);
 int _win_munmap(void *start, size_t length);
-int _win_lstat(const char *path, struct stat *buf);
+int _win_lstat(const char *path, struct _stat *buf);
 int _win_lstat64(const char *path, struct stat64 *buf);
 int _win_readlink(const char *path, char *buf, size_t bufsize);
 int _win_accept(int s, struct sockaddr *addr, int *addrlen);
@@ -610,6 +612,7 @@
                     int optlen);
 int _win_shutdown(int s, int how);
 int _win_socket(int af, int type, int protocol);
+int _win_socketpair(int af, int type, int protocol, int socket_vector[2]);
 struct hostent *_win_gethostbyaddr(const char *addr, int len, int type);
 struct hostent *_win_gethostbyname(const char *name);
 struct hostent *gethostbyname2(const char *name, int af);
@@ -658,6 +661,7 @@
  #define FOPEN(f, m) fopen(f, m)
  #define FCLOSE(f) fclose(f)
  #define FTRUNCATE(f, l) ftruncate(f, l)
+ #define TRUNCATE(f, l) truncate(f, l)
  #define OPENDIR(d) opendir(d)
  #define CLOSEDIR(d) closedir(d)
  #define READDIR(d) readdir(d)
@@ -722,6 +726,7 @@
  #define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
  #define SHUTDOWN(s, h) shutdown(s, h)
  #define SOCKET(a, t, p) socket(a, t, p)
+ #define SOCKETPAIR(a, t, p, v) socketpair(a, t, p, v)
  #define GETHOSTBYADDR(a, l, t) gethostbyaddr(a, l, t)
  #define GETHOSTBYNAME(n) gethostbyname(n)
  #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
@@ -756,6 +761,7 @@
  #define FOPEN(f, m) _win_fopen(f, m)
  #define FCLOSE(f) _win_fclose(f)
  #define FTRUNCATE(f, l) _win_ftruncate(f, l)
+ #define TRUNCATE(f, l) _win_truncate(f, l)
  #define OPENDIR(d) _win_opendir(d)
  #define CLOSEDIR(d) _win_closedir(d)
  #define READDIR(d) _win_readdir(d)
@@ -820,6 +826,7 @@
  #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
  #define SHUTDOWN(s, h) _win_shutdown(s, h)
  #define SOCKET(a, t, p) _win_socket(a, t, p)
+ #define SOCKETPAIR(a, t, p, v) _win_socketpair(a, t, p, v)
  #define GETHOSTBYADDR(a, l, t) _win_gethostbyaddr(a, l, t)
  #define GETHOSTBYNAME(n) _win_gethostbyname(n)
  #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
gnunet-plib_update.patch (5,181 bytes)   

Activities

Christian Grothoff

2013-09-13 15:02

manager   ~0007438

Did the downloads complete? Did you use gnunet-fs-gtk or gnunet-download?

bratao

2013-09-13 15:16

developer   ~0007440

The files were published using my own gui (cangote), as gnunet-fs-gtk was crashing.
I downloaded using gnunet-fs-gtk. All files was marked as completed.

I will try to publish and download using the command line tools to see if I can reproduce it.

Christian Grothoff

2013-09-13 21:50

manager   ~0007441

I've tried it with some small (JPG) and large (MP4) files here, and 'diff' reported no differences. Is the resulting file size the same? How did the corruption show?

bratao

2013-09-14 04:48

developer   ~0007444

I was downloading multiple files. Mostly of the (mp3) files, was skipping.

But one specific file, had part of the original mp3 and the other half was from another file.

But, I can't reproduce anymore with the latest SVN.

bratao

2013-09-14 05:02

developer   ~0007446

Well, it still happening.
Probably is a W32 error.

The file name is 01. Que Se Chama Amor - Só Pra Contrariar.mp3.

But it show this message:

Sep 14 00:00:15-00000000000200482707 gnunet-fs-gtk-7108 WARNING `truncate' faile
d on file `C:\sbuild\mine\gnunet-gtk\01. Que Se Chama Amor - S+¦ Pra Contrariar.
mp3' at fs_download.c:1773 with error: No such file or directory

bratao

2013-09-14 05:38

developer   ~0007448

Apparently there is a typo, and it's not calling PlibC truncate.

(12:33:16 AM) bratao: Wait
(12:33:41 AM) bratao: Aparentelly it is not calling plibc truncate.
(12:33:51 AM) bratao: mingw-w64 have a truncate
(12:34:21 AM) LRN: ah
(12:34:26 AM) LRN: AH!
(12:34:38 AM) LRN: it says "truncate", not "TRUNCATE", like it should
(12:35:26 AM) bratao: \o/

Christian Grothoff

2013-09-14 14:36

manager   ~0007449

LRN: If I use 'TRUNCATE", I get:

fs_download.c: In function 'try_match_block':
fs_download.c:544:10: warning: implicit declaration of function 'TRUNCATE' [-Wimplicit-function-declaration]

Christian Grothoff

2013-09-14 15:52

manager   ~0007451

Assigning to LRN as we need TRUNCATE in plibc to fix this.

bratao

2013-09-14 17:40

developer   ~0007452

I added a patch that fix and update the plibc includes.

Christian Grothoff

2013-09-14 18:14

manager   ~0007453

Fixed in SVN 29253.

Issue History

Date Modified Username Field Change
2013-09-13 03:03 bratao New Issue
2013-09-13 15:02 Christian Grothoff Note Added: 0007438
2013-09-13 15:03 Christian Grothoff Assigned To => Christian Grothoff
2013-09-13 15:03 Christian Grothoff Status new => feedback
2013-09-13 15:16 bratao Note Added: 0007440
2013-09-13 15:16 bratao Status feedback => assigned
2013-09-13 21:50 Christian Grothoff Note Added: 0007441
2013-09-13 21:50 Christian Grothoff Status assigned => feedback
2013-09-14 04:48 bratao Note Added: 0007444
2013-09-14 04:48 bratao Status feedback => assigned
2013-09-14 04:48 bratao Status assigned => resolved
2013-09-14 04:48 bratao Resolution open => fixed
2013-09-14 05:02 bratao Note Added: 0007446
2013-09-14 05:02 bratao Status resolved => feedback
2013-09-14 05:02 bratao Resolution fixed => reopened
2013-09-14 05:36 bratao Status feedback => assigned
2013-09-14 05:38 bratao Note Added: 0007448
2013-09-14 14:36 Christian Grothoff Note Added: 0007449
2013-09-14 15:52 Christian Grothoff Summary File downloaded get corrupted => File downloaded get corrupted / TRUNCATE needed in plibc
2013-09-14 15:52 Christian Grothoff Note Added: 0007451
2013-09-14 15:52 Christian Grothoff Assigned To Christian Grothoff => LRN
2013-09-14 17:40 bratao File Added: gnunet-plib_update.patch
2013-09-14 17:40 bratao Note Added: 0007452
2013-09-14 18:14 Christian Grothoff Note Added: 0007453
2013-09-14 18:14 Christian Grothoff Status assigned => resolved
2013-09-14 18:14 Christian Grothoff Fixed in Version => 0.10.0
2013-09-14 18:14 Christian Grothoff Resolution reopened => fixed
2013-09-14 18:15 Christian Grothoff Product Version => Git master
2013-09-14 18:15 Christian Grothoff Target Version => 0.10.0
2013-12-24 20:54 Christian Grothoff Status resolved => closed