[GRASS5] [DebianGIS-dev] Bug#336498: grass: broken macro LOC_CHECK_VERSION (also FTBFS on GNU/FreeBSD)

Fwd from the Debian Bug Tracker--

Begin forwarded message:

Date: Sun, 30 Oct 2005 20:14:39 +0100 (CET)
From: Petr Salinger <Petr.Salinger@t-systems.cz>
To: submit@bugs.debian.org
Subject: [DebianGIS-dev] Bug#336498: grass: broken macro LOC_CHECK_VERSION (also FTBFS on GNU/FreeBSD)

Package: grass
Severity: important

Please split macro LOC_CHECK_VERSION from aclocal
into LOC_CHECK_VERSION_STRING and LOC_CHECK_VERSION_NUMBER
and use them appropriate in configure.in.

Current version check is unreliable.

Generated snippet, i.e.:

#include "confdefs.h"

#include <stdio.h>
#include <proj_api.h>
int main(void) {
FILE *fp = fopen("conftestdata","w");
char *p;
p = PJ_VERSION;
fputs(p, fp);
return 0;
}

is compiled OK, only with "warning: assignment makes pointer from integer
without a cast".

When the created binary is executed, random (given by arbitrary version
integer) memory is accessed and result might be either segfault or garbage from memory.

It currently segfault on GNU/Linux => package can be compiled
and returns garbage on GNU/FreeBSD => it FTBFS there.

It would be nice if you could get fixed it into upstream.

Temporarily the attached patch can be also used.

Thanks in advance,

        Petr

--- grass-6.0.1.orig/configure
+++ grass-6.0.1/configure
@@ -6421,31 +6421,6 @@
     echo "$ac_t""unknown (cross-compiling)" 1>&6
else
   cat > conftest.$ac_ext <<EOF
-#line 6425 "configure"
-#include "confdefs.h"
-
-#include <stdio.h>
-#include <proj_api.h>
-int main(void) {
- FILE *fp = fopen("conftestdata","w");
- fputs(PJ_VERSION, fp);
- return 0;
-}
-
-EOF
-if { (eval echo configure:6437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- proj_ver=`cat conftestdata`
- echo "$ac_t""$proj_ver" 1>&6
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- if test "$cross_compiling" = yes; then
- proj_ver=UNKNOWN
- echo "$ac_t""unknown (cross-compiling)" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
#line 6450 "configure"
#include "confdefs.h"

@@ -6471,11 +6446,6 @@
rm -fr conftest*
fi

-
-fi
-rm -fr conftest*
-fi
-
CPPFLAGS=$ac_save_cppflags

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-grass-devel

Does anyone know how to modify 'configure.in' for this problem?

Thanks

Markus

Hamish wrote:

Fwd from the Debian Bug Tracker--

Begin forwarded message:

Date: Sun, 30 Oct 2005 20:14:39 +0100 (CET)
From: Petr Salinger <Petr.Salinger@t-systems.cz>
To: submit@bugs.debian.org
Subject: [DebianGIS-dev] Bug#336498: grass: broken macro LOC_CHECK_VERSION (also FTBFS on GNU/FreeBSD)

Package: grass
Severity: important

Please split macro LOC_CHECK_VERSION from aclocal
into LOC_CHECK_VERSION_STRING and LOC_CHECK_VERSION_NUMBER
and use them appropriate in configure.in.

Current version check is unreliable.

Generated snippet, i.e.:

#include "confdefs.h"

#include <stdio.h>
#include <proj_api.h>
int main(void) {
FILE *fp = fopen("conftestdata","w");
char *p;
p = PJ_VERSION;
fputs(p, fp);
return 0;
}

is compiled OK, only with "warning: assignment makes pointer from integer
without a cast".

When the created binary is executed, random (given by arbitrary version
integer) memory is accessed and result might be either segfault or garbage from memory.

It currently segfault on GNU/Linux => package can be compiled
and returns garbage on GNU/FreeBSD => it FTBFS there.

It would be nice if you could get fixed it into upstream.

Temporarily the attached patch can be also used.

Thanks in advance,

       Petr

--- grass-6.0.1.orig/configure
+++ grass-6.0.1/configure
@@ -6421,31 +6421,6 @@
    echo "$ac_t""unknown (cross-compiling)" 1>&6
else
  cat > conftest.$ac_ext <<EOF
-#line 6425 "configure"
-#include "confdefs.h"
-
-#include <stdio.h>
-#include <proj_api.h>
-int main(void) {
- FILE *fp = fopen("conftestdata","w");
- fputs(PJ_VERSION, fp);
- return 0;
-}
-
-EOF
-if { (eval echo configure:6437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- proj_ver=`cat conftestdata`
- echo "$ac_t""$proj_ver" 1>&6
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- if test "$cross_compiling" = yes; then
- proj_ver=UNKNOWN
- echo "$ac_t""unknown (cross-compiling)" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
#line 6450 "configure"
#include "confdefs.h"

@@ -6471,11 +6446,6 @@
rm -fr conftest*
fi

-
-fi
-rm -fr conftest*
-fi
-
CPPFLAGS=$ac_save_cppflags

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-grass-devel

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5

On 03/11/05 16:57, Markus Neteler wrote:

Does anyone know how to modify 'configure.in' for this problem?

LOC_CHECK_VERSION does 2 tests. First it tries to compile this program:
#include "confdefs.h"

#include <stdio.h>
#include <proj_api.h>
int main(void) {
FILE *fp = fopen("conftestdata","w");
fputs(PJ_VERSION, fp);
return 0;
}

Since PJ_VERSION is defined to be 449 or some similar number this will
produce a compiler warning. -Werror will make gcc act as if warning are
errors ==> compilation fails and this is never run. The macro then tries
to build this program:

#include "confdefs.h"

#include <stdio.h>
#include <$1>
int main(void) {
FILE *fp = fopen("conftestdata","w");
fprintf(fp, "%d", $2);
return 0;
}

which will compile in this case, and write the version to the
conftestdata file.

So to fix this all you need to do is introduce the -Werror flag to the
gcc commandline, which is trivial to do. All you need to do is modify
configure.in line 516. Add -Werror to the 5th parameter of the macro call.

Your line should now look something like this: (without linebreaks).

LOC_CHECK_VERSION(proj_api.h,PJ_VERSION,
    External PROJ.4,proj_ver,$PROJINC -Werror,UNKNOWN)

I don't have a BSD to test on so I can't say if this works or not, but
on GNU/Linux PowerPC it does work.

--Wolf

--

<:3 )---- Wolf Bergenheim ----( 8:>

Markus Neteler wrote:

>Please split macro LOC_CHECK_VERSION from aclocal
>into LOC_CHECK_VERSION_STRING and LOC_CHECK_VERSION_NUMBER
>and use them appropriate in configure.in.

Does anyone know how to modify 'configure.in' for this problem?

I've committed the following changes:

1. In aclocal.m4, replace LOC_CHECK_VERSION with:

AC_DEFUN(LOC_CHECK_VERSION_STRING,[
AC_MSG_CHECKING($3 version)
ac_save_cppflags="$CPPFLAGS"
CPPFLAGS="$5 $CPPFLAGS"
AC_TRY_RUN([
#include <stdio.h>
#include <$1>
int main(void) {
FILE *fp = fopen("conftestdata","w");
fputs($2, fp);
return 0;
}
],
[ $4=`cat conftestdata`
    AC_MSG_RESULT($$4)],
[ AC_MSG_ERROR([*** Could not determine $3 version.]) ],
[ $4=$6
    AC_MSG_RESULT([unknown (cross-compiling)]) ])
CPPFLAGS=$ac_save_cppflags
])

AC_DEFUN(LOC_CHECK_VERSION_INT,[
AC_MSG_CHECKING($3 version)
ac_save_cppflags="$CPPFLAGS"
CPPFLAGS="$5 $CPPFLAGS"
AC_TRY_RUN([
#include <stdio.h>
#include <$1>
int main(void) {
FILE *fp = fopen("conftestdata","w");
fprintf(fp, "%d", $2);
return 0;
}
    ],
    [ $4=`cat conftestdata`
        AC_MSG_RESULT($$4)],
    [ AC_MSG_ERROR([*** Could not determine $3 version.]) ],
    [ $4=$6
        AC_MSG_RESULT([unknown (cross-compiling)]) ])
CPPFLAGS=$ac_save_cppflags
])

2. In configure.in:

a) replace:

  LOC_CHECK_VERSION(proj_api.h,PJ_VERSION,External PROJ.4,proj_ver,$PROJINC,UNKNOWN)
with:
  LOC_CHECK_VERSION_INT(proj_api.h,PJ_VERSION,External PROJ.4,proj_ver,$PROJINC,0)

b) replace:

  LOC_CHECK_VERSION(tcl.h,TCL_VERSION,Tcl,tcl_ver,$TCLINCDIR,UNKNOWN)
with:
  LOC_CHECK_VERSION_STRING(tcl.h,TCL_VERSION,Tcl,tcl_ver,$TCLINCDIR,UNKNOWN)

c) replace:

  LOC_CHECK_VERSION(tk.h,TK_VERSION,Tk,tk_ver,$TCLINCDIR $X_CFLAGS,UNKNOWN)
with:
  LOC_CHECK_VERSION_STRING(tk.h,TK_VERSION,Tk,tk_ver,$TCLINCDIR $X_CFLAGS,UNKNOWN)

--
Glynn Clements <glynn@gclements.plus.com>