reopen 387183 !
thanks

Package: ctn
Version: 3.0.6-9
Tags: patch
Followup-For: Bug #387183


While chasing down a rc bug in dicomnifti package
I've realized that U32 size on amd64 provided by ctn is 64 bit (which is
wrong). That caused valgrind to report multiple improper read/writes
(writing/reading 8 bytes into 4 bytes available, etc)

It seems as of now ctn is not dynamicaly figuring out the sizes, so
I've decided to write a tiny C shippet which would spit out proper
sizes. You can see the patch which makes ctn valgrind-happy at the end
(and dicomnifti as well if it gets rebuilt properly)

Please don't simply apply this patch but tune it so provided sizes are
properly incorporated into dicom.h, since otherwise any tool which
compiles using ctn/*.h will have no information on *SIZE variables, so
it would need to define them.

now windows specific dicom_platform.h sounds like a good place where to
dump the values, and make it unconditionally included into dicom.h. For
windows boxes (since debian doesn't get compiled there) I bet they are
safe to use it as is ;-)

Cheers

-- System Information:
Debian Release: testing/unstable
  APT prefers testing-proposed-updates
  APT policy: (500, 'testing-proposed-updates'), (500, 'testing')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-2-amd64-generic
Locale: LANG=ru_RU.KOI8-R, LC_CTYPE=ru_RU.KOI8-R (charmap=KOI8-R)

Versions of packages ctn depends on:
ii  libc6                        2.3.6.ds1-7 GNU C Library: Shared libraries
ii  libmysqlclient15off          5.0.30-3    mysql database client library
ii  libx11-6                     2:1.0.3-2   X11 client-side library
ii  libxaw7                      1:1.0.2-4   X11 Athena Widget library
ii  libxext6                     1:1.0.1-2   X11 miscellaneous extension librar
ii  libxmu6                      1:1.0.2-2   X11 miscellaneous utility library
ii  libxt6                       1:1.0.2-2   X11 toolkit intrinsics library
ii  zlib1g                       1:1.2.3-13  compression library - runtime

ctn recommends no packages.

-- no debconf information

-- 
                                  .-.
=------------------------------   /v\  ----------------------------=
Keep in touch                    // \\     (yoh@|www.)onerussian.com
Yaroslav Halchenko              /(   )\               ICQ#: 60653192
                   Linux User    ^^-^^    [175555]


diff -Naur ctn-3.0.6/debian/ctnmake.debian.mysql.options 
ctn-3.0.6.good/debian/ctnmake.debian.mysql.options
--- ctn-3.0.6/debian/ctnmake.debian.mysql.options       2007-01-26 
10:16:36.000000000 -0500
+++ ctn-3.0.6.good/debian/ctnmake.debian.mysql.options  2007-01-26 
09:44:21.439319106 -0500
@@ -23,9 +23,6 @@
 CFLAGS_MOTIF = -I$(XM_INCLUDE)
 
 #DEBUG_LIBS = -lmalloc
-LONGSIZE=32
-INTSIZE=32
-SHORTSIZE=16
 C_OPTS = -g -DDEBUG -D$(ARCHITECTURE) -D$(OS) -DSHARED_MEMORY \
 -DSEMAPHORE -DX11 -DATHENA -DX11R4 -DUSLEEP -DMYSQLDB \
 -I$(DICOM_INCLUDE) -I$(MYSQL_INCLUDE) \
diff -Naur ctn-3.0.6/debian/debian.mysql.options.env 
ctn-3.0.6.good/debian/debian.mysql.options.env
--- ctn-3.0.6/debian/debian.mysql.options.env   2007-01-26 10:16:36.000000000 
-0500
+++ ctn-3.0.6.good/debian/debian.mysql.options.env      2007-01-26 
09:44:36.996802694 -0500
@@ -6,7 +6,7 @@
 export DICOM_LIB=$DICOM_ROOT/lib/ctn-mysql
 export DICOM_LIBSRC=$DICOM_ROOT/libsrc
 export DICOM_INCLUDE=$DICOM_ROOT/include 
-export DICOM_MAKE=$DICOM_ROOT/debian/ctnmake.debian.mysql.options
+export DICOM_MAKE=$DICOM_ROOT/debian/ctnmake.debian.mysql.options.full
 
 export MYSQL_LIB=/usr/lib
 export MYSQL_INCLUDE=/usr/include/mysql
diff -Naur ctn-3.0.6/debian/make_sizes.c ctn-3.0.6.good/debian/make_sizes.c
--- ctn-3.0.6/debian/make_sizes.c       1969-12-31 19:00:00.000000000 -0500
+++ ctn-3.0.6.good/debian/make_sizes.c  2007-01-26 09:52:56.732459943 -0500
@@ -0,0 +1,7 @@
+#include <stdio.h>
+int main(){ 
+    printf("LONGSIZE=%d\n", 8*sizeof(long int));
+    printf("INTSIZE=%d\n", 8*sizeof(int));
+    printf("SHORTSIZE=%d\n", 8*sizeof(short));
+return 0;
+}
diff -Naur ctn-3.0.6/debian/README.Debian ctn-3.0.6.good/debian/README.Debian
--- ctn-3.0.6/debian/README.Debian      2007-01-26 10:16:36.000000000 -0500
+++ ctn-3.0.6.good/debian/README.Debian 2007-01-26 10:18:35.835303789 -0500
@@ -26,15 +26,3 @@
 
   4. Added man pages. 
 
-
-Using CTN with other code on 64 bit platforms
----------------------------------------------
-Michael Hanke writes:
-"If I got it right LONGSIZE has to be defined 32 in any code that uses
-CTN no matter what the actual size of long is. 
-
-I have some code that normally determines the size of long in a platform check
-(obviously 64 on amd64). If I define LONGSIZE to match the size of long
-on amd64 I get a segfault when calling CTN stuff."
-
-
diff -Naur ctn-3.0.6/debian/rules ctn-3.0.6.good/debian/rules
--- ctn-3.0.6/debian/rules      2007-01-26 10:16:36.000000000 -0500
+++ ctn-3.0.6.good/debian/rules 2007-01-26 09:44:53.266354190 -0500
@@ -15,9 +15,10 @@
 
 build: build-stamp
 
-build-stamp: 
+build-stamp: debian/make_sizes
        dh_testdir
-
+       debian/make_sizes >| debian/ctnmake.debian.mysql.options.full
+       cat debian/ctnmake.debian.mysql.options >> 
debian/ctnmake.debian.mysql.options.full
        # Add here commands to compile the package.
        (. debian/debian.mysql.options.env; make install)
        touch build-stamp
@@ -30,6 +31,7 @@
        # Add here commands to clean up after the build process.
        -$(MAKE) clean
        rm -f debian/ctn*.postinst.* debian/ctn*.prerm.*
+       rm -f debian/ctnmake.debian.mysql.options.full debian/make_sizes
        rm -rf ${build}
        rm -f libsrc/*.c libsrc/*.h
        rm -f `find . -name \*.o -or -name \*.a`
diff -Naur ctn-3.0.6/facilities/dicom/dicom.h 
ctn-3.0.6.good/facilities/dicom/dicom.h
--- ctn-3.0.6/facilities/dicom/dicom.h  1999-09-23 22:53:14.000000000 -0400
+++ ctn-3.0.6.good/facilities/dicom/dicom.h     2007-01-26 09:22:39.000000000 
-0500
@@ -85,14 +85,20 @@
     typedef unsigned short U16;        /* unsigned, 16 bit */
     typedef short S16;         /* signed, 16 bit */
 
-#if LONGSIZE == 64 && INTSIZE == 32    /* Such as an Alpha */
+/* Most if not all platforms have 8bit int but long is 64 bit 
+ * on 64bit platforms. So it must be safe to use int for all of
+ * them
+ *
+ * This seems to be an echo of
+ * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=387183
+ * */
+#if INTSIZE == 32
     typedef unsigned int U32;
     typedef int S32;
 
 #elif LONGSIZE == 32           /* Most 32 bit workstations */
     typedef unsigned long U32;
     typedef long S32;
-
 #else                          /* Something we do not support */
 
 /* The writers of this code assume that we can find a 32 bit integer

Reply via email to