summary refs log tree commit diff
path: root/pkgs/applications/graphics/hugin
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-07-13 16:24:47 +0000
committerLudovic Courtès <ludo@gnu.org>2009-07-13 16:24:47 +0000
commited658483e9e42198a5cbbeff950ecbf8a12bc330 (patch)
tree394a6de90b5434dbcb2c5a3e39df1aafa22d893c /pkgs/applications/graphics/hugin
parentb09382fcd1baa62df37253594a65cef6dfb4fa48 (diff)
downloadnixpkgs-ed658483e9e42198a5cbbeff950ecbf8a12bc330.tar
nixpkgs-ed658483e9e42198a5cbbeff950ecbf8a12bc330.tar.gz
nixpkgs-ed658483e9e42198a5cbbeff950ecbf8a12bc330.tar.bz2
nixpkgs-ed658483e9e42198a5cbbeff950ecbf8a12bc330.tar.lz
nixpkgs-ed658483e9e42198a5cbbeff950ecbf8a12bc330.tar.xz
nixpkgs-ed658483e9e42198a5cbbeff950ecbf8a12bc330.tar.zst
nixpkgs-ed658483e9e42198a5cbbeff950ecbf8a12bc330.zip
Hugin: Fix segfault on x86_64.
svn path=/nixpkgs/trunk/; revision=16340
Diffstat (limited to 'pkgs/applications/graphics/hugin')
-rw-r--r--pkgs/applications/graphics/hugin/default.nix2
-rw-r--r--pkgs/applications/graphics/hugin/levmar-64-bit-alignment.patch64
2 files changed, 66 insertions, 0 deletions
diff --git a/pkgs/applications/graphics/hugin/default.nix b/pkgs/applications/graphics/hugin/default.nix
index 92156959750..ae6b7a43d02 100644
--- a/pkgs/applications/graphics/hugin/default.nix
+++ b/pkgs/applications/graphics/hugin/default.nix
@@ -9,6 +9,8 @@ stdenv.mkDerivation {
     sha256 = "0nbrvzz94gqgk2v1900lly101g0wjz4zksnh5718226n2g8zlccf";
   };
 
+  patches = [ ./levmar-64-bit-alignment.patch ];
+
   NIX_CFLAGS_COMPILE = "-I${ilmbase}/include/OpenEXR";
 
   NIX_LDFLAGS = "-lrt";
diff --git a/pkgs/applications/graphics/hugin/levmar-64-bit-alignment.patch b/pkgs/applications/graphics/hugin/levmar-64-bit-alignment.patch
new file mode 100644
index 00000000000..b0c39e378ec
--- /dev/null
+++ b/pkgs/applications/graphics/hugin/levmar-64-bit-alignment.patch
@@ -0,0 +1,64 @@
+This patch fixes alignment issues on 64-bit machines.  It was taken
+from http://www.mail-archive.com/hugin-ptx@googlegroups.com/msg02976.html .
+See also http://thread.gmane.org/gmane.linux.distributions.nixos/2352 .
+
+--- hugin/src/foreign/levmar/misc_core.c	2009-04-28 13:30:33.000000000 +0200 # SVN 3799
++++ hugin/src/foreign/levmar/misc_core.c	2009-05-04 07:49:00.000000000 +0200 # Merged patch.pt and fix_alias.diff
+@@ -332,7 +332,7 @@
+   a_sz=m*m;
+   u_sz=m*m; s_sz=m; vt_sz=m*m;
+ 
+-  tot_sz=iworksz*sizeof(int) + (a_sz + u_sz + s_sz + vt_sz + worksz)*sizeof(LM_REAL);
++  tot_sz=(a_sz + u_sz + s_sz + vt_sz + worksz)*sizeof(LM_REAL) + iworksz*sizeof(int); /* should be arranged in that order for proper doubles alignment */
+ 
+     buf_sz=tot_sz;
+     buf=(LM_REAL *)malloc(buf_sz);
+@@ -414,25 +414,27 @@
+ int buf_sz=0;
+ 
+ register int i, j, k, l;
+-int *idx, maxi=-1, idx_sz, a_sz, x_sz, work_sz, tot_sz;
++int *idxbuf, *idx, maxi=-1, idx_sz, a_sz, x_sz, work_sz, tot_sz;
+ LM_REAL *a, *x, *work, max, sum, tmp;
+ 
+   /* calculate required memory size */
+   idx_sz=m;
++  idxbuf=(void *)malloc(idx_sz*sizeof(int));
++
+   a_sz=m*m;
+   x_sz=m;
+   work_sz=m;
+-  tot_sz=idx_sz*sizeof(int) + (a_sz+x_sz+work_sz)*sizeof(LM_REAL);
++  tot_sz=(a_sz + x_sz + work_sz)*sizeof(LM_REAL) + idx_sz*sizeof(int); /* should be arranged in that order for proper doubles alignment */
+ 
+   buf_sz=tot_sz;
+   buf=(void *)malloc(tot_sz);
+-  if(!buf){
++  if(!buf || !idxbuf){
+     fprintf(stderr, RCAT("memory allocation in ", LEVMAR_LUINVERSE) "() failed!\n");
+     exit(1);
+   }
+ 
+-  idx=(int *)buf;
+-  a=(LM_REAL *)(idx + idx_sz);
++  idx=(int *)idxbuf;
++  a=(LM_REAL *)buf;
+   x=a + a_sz;
+   work=x + x_sz;
+ 
+@@ -448,6 +450,7 @@
+ 		  if(max==0.0){
+         fprintf(stderr, RCAT("Singular matrix A in ", LEVMAR_LUINVERSE) "()!\n");
+         free(buf);
++	free(idxbuf);
+ 
+         return 0;
+       }
+@@ -522,6 +525,7 @@
+   }
+ 
+   free(buf);
++  free(idxbuf);
+ 
+   return 1;
+ }