Bug 57800

Summary: Probable non-64bit-cleanness of unrar
Product: Ports & Packages Reporter: Holger Lamm <holger>
Component: Individual Port(s)Assignee: Andrey A. Chernov <ache>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Holger Lamm 2003-10-09 15:20:11 UTC
While extracting, some files (about 1 out of 40) have CRC incorrect.
Extracting unter i386 works.

The files show compression method "m5g", the archive was created 
under Windows.
Trying to reproduce the problem with UNIX rar (method m3b or m5b) shows
no problem.

(How do I create method m5g?)

How-To-Repeat: 
Get a RAR with method m5g. Uncompress with archivers/unrar under sparc64.
Comment 1 Holger Lamm 2003-10-09 15:41:50 UTC
Program author (roshal@rarlab.com) informed.
Dunno if he feels responsible.
Comment 2 Holger Lamm 2003-10-09 17:09:46 UTC
---- Anwer from author ----
Date: Thu, 9 Oct 2003 21:51:18 +0600
From: Eugene Roshal <roshal@rarlab.com>
Subject: Re: Probable non-64bit-cleanness in unrar

Hello,
  
Unfortunately I am not able to debug unrar for this platform
myself. Please check that you set correct data types in rartypes.hpp,
for example, strict 32 bits for uint32. Also you need to enable
1 byte alignment for structures in model.hpp. Now it contains
'#pragma pack(1)' directive, but your compiler may require  
something else. Also try to disable compiler optimization,  
sometimes it may cause errors because of bugs in compiler.
  
Eugene
--------------------------
Comment 3 John-Mark Gurney freebsd_committer freebsd_triage 2003-10-28 04:28:41 UTC
Responsible Changed
From-To: freebsd-sparc64->freebsd-ports

this is a port problem, yes it fails on sparc64, but if we had other 
64bit big-en platforms, it'd fail there too.. If someone has a patch that 
makes this work, but doesn't have a box to try it on, I'm willing to 
test patches.
Comment 4 Tilman Keskinoz freebsd_committer freebsd_triage 2003-10-28 09:45:53 UTC
Responsible Changed
From-To: freebsd-ports->ache

ache maintains unrar
Comment 5 Andrey A. Chernov freebsd_committer freebsd_triage 2003-10-28 10:21:10 UTC
State Changed
From-To: open->feedback

If even author and sparc64 people can't fix it, I can't even more. 
If you'll come with patch, send it to author and me.
Comment 6 ryan 2004-01-04 23:43:46 UTC
This bug has also been reported for Gentoo Linux on the AMD64, and I 
believe I have a fix that should also apply to FreeBSD on sparc64.

Details are here:
   http://bugs.gentoo.org/show_bug.cgi?id=34872

--ryan.
Comment 7 Holger Lamm 2004-01-05 14:31:15 UTC
 > This bug has also been reported for Gentoo Linux on the AMD64, and I
 > believe I have a fix that should also apply to FreeBSD on sparc64.

Fine, it works. Fixes it on Sparc64 and obviously on AMD64 as well.
Here is the patch for the port. I increased PORTREVISION to make
sparc64 owners update:

diff -Nur unrar.orig/Makefile unrar/Makefile
--- unrar.orig/Makefile Mon Jan  5 14:17:07 2004
+++ unrar/Makefile      Mon Jan  5 14:22:08 2004
@@ -7,6 +7,7 @@

  PORTNAME=      unrar
  PORTVERSION=   3.20
+PORTREVISION=  1
  PORTEPOCH=     2
  CATEGORIES=    archivers
  MASTER_SITES=  http://files10.rarlab.com/rar/
diff -Nur unrar.orig/files/patch-rarvm.cpp unrar/files/patch-rarvm.cpp
--- unrar.orig/files/patch-rarvm.cpp    Thu Jan  1 00:00:00 1970
+++ unrar/files/patch-rarvm.cpp Mon Jan  5 13:29:42 2004
@@ -0,0 +1,13 @@
+--- rarvm.cpp.orig     2004-01-04 18:28:01.532948504 -0500
++++ rarvm.cpp  2004-01-04 18:28:20.920001224 -0500
+@@ -791,8 +791,8 @@
+           CurPos++;
+           if (CurByte==0xe8 || CurByte==CmpByte2)
+           {
+-            long Offset=CurPos+FileOffset;
+-            long Addr=GET_VALUE(false,Data);
++            int Offset=CurPos+FileOffset;
++            int Addr=GET_VALUE(false,Data);
+             if (Addr<0)
+             {
+               if (Addr+Offset>=0)

CU,
Holger
Comment 8 Андрей Чернов 2004-01-06 00:38:26 UTC
On Mon, Jan 05, 2004 at 03:31:15PM +0100, Holger Lamm wrote:

> +-            long Offset=CurPos+FileOffset;
> +-            long Addr=GET_VALUE(false,Data);
> ++            int Offset=CurPos+FileOffset;
> ++            int Addr=GET_VALUE(false,Data);

I dislike this fix, it may produce different results on different 
architectures. Better use types like int32_t

-- 
Andrey Chernov | http://ache.pp.ru/
Comment 9 Holger Lamm 2004-01-09 12:24:47 UTC
Hi,
> Do you discuss this patch with RAR author? 

Indeed I did. Here is his answer:

-------------------------------------
From: Eugene Roshal <roshal@rarlab.com>
To:   Holger Lamm <holger@e-gitt.net>
Date: 07.01.2004 16:00
Subject: Re: Fixed: 64bit-uncleanness of unrar

Hello,

Thank you.

I already updated unrar source on www.rarlab.com,
but unfortunately I cannot recompile unrar for Sparc myself.
I hope, someone will send me the updated unrar/Sparc binary.

Eugene
-------------------------------------
[The ports's sourcefile unrarsrc-3.2.3.tar.gz is unchanged]

By the way, I noticed the current version of RAR is 3.3.4.
Why not just upgrade the port? (OK, 3.3 is still beta.)

Regards,
Holger

----------------------- snip ---------------------------
diff -Nur unrar.orig/Makefile unrar/Makefile
--- unrar.orig/Makefile Mon Jan  5 15:17:07 2004
+++ unrar/Makefile      Fri Jan  9 13:13:37 2004
@@ -6,11 +6,11 @@
  #

  PORTNAME=      unrar
-PORTVERSION=   3.20
+PORTVERSION=   3.30
  PORTEPOCH=     2
  CATEGORIES=    archivers
  MASTER_SITES=  http://files10.rarlab.com/rar/
-DISTNAME=      unrarsrc-3.2.3
+DISTNAME=      unrarsrc-3.3.4

  MAINTAINER=    ache@FreeBSD.org
  COMMENT=       Extract, view & test RAR archives
diff -Nur unrar.orig/distinfo unrar/distinfo
--- unrar.orig/distinfo Mon Jan  5 15:17:07 2004
+++ unrar/distinfo      Fri Jan  9 13:13:51 2004
@@ -1 +1 @@
-MD5 (unrarsrc-3.2.3.tar.gz) = 1afca3128e21994042f34bcb91b4ea48
+MD5 (unrarsrc-3.3.4.tar.gz) = 56565ef8e66416a507b4403128b97990
--------------------------------------------------------
Comment 10 Pav Lucistnik freebsd_committer freebsd_triage 2004-02-28 23:04:29 UTC
State Changed
From-To: feedback->closed

Looking into sources of actual port's distfile (3.3.5), 
this has been solved upstream.