[MINC-users] Minc 1.5.1 64-bit compatibility bug

Alexandre CARMEL-VEILLEUX acveilleux at mrs.mni.mcgill.ca
Tue Jul 22 13:54:37 EDT 2008


Hi,

	Minc 1.5.1 includes ParseArgv as part of libminc. This library
provides the argument parsing support for most libtools. rawtominc (and
probably others) misuse ParseArgv when dealing with constants.

The offending code looks like:

/* Argument table */
ArgvInfo argTable[] = {
// ... snip ...
   {"-nomodality", ARGV_CONSTANT, NULL, (char *) &modality,
       "Do not store modality type in file."},
   "-pet", ARGV_CONSTANT, MI_PET, (char *) &modality,
       "PET data."},
   {"-mri", ARGV_CONSTANT, MI_MRI, (char *) &modality,
       "MRI data."},
// ... snip ...

In ParseArgv however the arguments gets converted to an int:

      case ARGV_CONSTANT:
         *((int *) infoPtr->dst) = *((int*)(&infoPtr->src));
	 break;

On 64-bit platforms this causes the upper 32-bit of the pointers to be
dropped.

On subsequent use by rawtominc, the whole thing breaks because rawtominc
still expects a pointer:

   /* Create the modality attribute */
   if (modality != NULL) {
      varid = micreate_group_variable(cdfid, MIstudy);
      (void) miattputstr(cdfid, varid, MImodality, modality);
   }

Output (with extra debugging, line offset off by 1 due to fprintf):

(gdb) run test.mnc 60 256 192 -clobber -mri
Starting program: /localscratch/compile/minc-1.5.1/progs/rawtominc/rawtominc test.mnc 60 256 192 -clobber -mri
Reading symbols for shared libraries ++. done
miattputstr(cdfid, varid, MImodality, modality) where:
	 modality(int) = 200150
	modality(pointer) = 0x30dd6
	modality(actual pointer) = 0x100030dd6

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000030dd0
0x00007fff80a3a0d0 in strlen ()
(gdb) bt
#0  0x00007fff80a3a0d0 in strlen ()
#1  0x000000010000cfe8 in miattputstr ()
#2  0x0000000100001b1b in main (argc=7, argv=0x7fff5fbff488) at progs/rawtominc/rawtominc.c:636
(gdb)

	I don't have access to fix this in the CVS. When this is dealt
with, I'll update my 64-bit os-x 10.5 tarball.

Alex


More information about the MINC-users mailing list