Milan Knížek píše v Ne 03. 05. 2009 v 14:15 +0200:
> Lukáš Jirkovský píše v St 29. 04. 2009 v 18:37 +0200:
> > I've backported the changes from levmar 2.4. It doesn't seems to break
> > anything (and I'm not experiencing so much strange results, but it
> > could be luck). Patch is attached. Could you please test it, Milan?
> 
> This patch conflicts with the other patch [1], which originally solved
> the segfault.
> 
> When I use only your patch with backports of levmar 2.4, then hugin
> behaves the same as before - it segfaults on exposure optimisation.
> 
> I have tried to merge the patches, hugin compiled fine but during
> exposure optimisation it produced even different type of errors. Maybe I
> did the merger wrong, I will try again later.
> 
> [1]
> http://sourceforge.net/tracker/?func=detail&aid=2055537&group_id=77506&atid=550443
> 
I tried again to merge the two patches, this time with more luck (I am
not a programmer, so I just did my best at guessing).

Finally, hugin does not segfault on exposure optimisation for me and
seems to work normally.

Attached is the diff file against svn 3799, it should be probably
checked by someone knowledgeable.

regards,

Milan Knizek
knizek (dot) confy (at) volny (dot) cz
http://www.milan-knizek.net - About linux and photography (Czech
language only)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/hugin-ptx
-~----------~----~----~----~------~----~------~--~---

--- src/foreign/levmar/misc_core.c	2009-04-28 13:30:33.000000000 +0200 # SVN 3799
+++ 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;
 }

Reply via email to