#459 m4:CL_INTPARAM_ALIGNOF loops infinitely when cross-compiling

build problems
closed-fixed
Sam Steingold
clisp (525)
5
2008-03-31
2008-03-30
No

the macro CL_INTPARAM_ALIGNOF defined at the bottom
of src/m4/intparam.m4 produces an infinite loop when
using cross-compiler.

eventually i get an infinite sequence of "expr: syntax error" messages when running configure script:

expr: *: Numerical result out of range
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
[...]

n becomes too big for expr to handle it. the first message is an overflow, and then the literal integers are not recognized as integers anymore because they're too big.

excerpt from configure run with the with the tracing enabled:

==============================================
++ expr 1152921504606846976 '*' 2
+ n=2305843009213693952
+ true
+ cat
+ cat confdefs.h
+ cat
+ rm -f conftest.o
+ ac_try='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ case "(($ac_try" in
+ ac_try_echo='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ eval 'echo "$as_me:53764: $CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5"'
++ echo 'configure:53764: i586-mingw32msvc-gcc -c -g -O2 -I/home/vvv/src/clisp/clisp-tools/include conftest.c >&5'
+ ac_status=1
+ grep -v '^ *+' conftest.er1
+ rm -f conftest.er1
+ cat conftest.err
+ echo 'configure:53770: $? = 1'
+ exit 1
+ echo 'configure: failed program was:'
+ sed 's/^/| /' conftest.c
+ rm -f core conftest.err conftest.o conftest.c
++ expr 2305843009213693952 '*' 2
+ n=4611686018427387904
+ true
+ cat
+ cat confdefs.h
+ cat
+ rm -f conftest.o
+ ac_try='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ case "(($ac_try" in
+ ac_try_echo='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ eval 'echo "$as_me:53764: $CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5"'
++ echo 'configure:53764: i586-mingw32msvc-gcc -c -g -O2 -I/home/vvv/src/clisp/clisp-tools/include conftest.c >&5'
+ ac_status=1
+ grep -v '^ *+' conftest.er1
+ rm -f conftest.er1
+ cat conftest.err
+ echo 'configure:53770: $? = 1'
+ exit 1
+ echo 'configure: failed program was:'
+ sed 's/^/| /' conftest.c
+ rm -f core conftest.err conftest.o conftest.c
++ expr 4611686018427387904 '*' 2
expr: *: Numerical result out of range
+ n=
+ true
+ cat
+ cat confdefs.h
+ cat
+ rm -f conftest.o
+ ac_try='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ case "(($ac_try" in
+ ac_try_echo='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ eval 'echo "$as_me:53764: $CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5"'
++ echo 'configure:53764: i586-mingw32msvc-gcc -c -g -O2 -I/home/vvv/src/clisp/clisp-tools/include conftest.c >&5'
+ ac_status=1
+ grep -v '^ *+' conftest.er1
+ rm -f conftest.er1
+ cat conftest.err
+ echo 'configure:53770: $? = 1'
+ exit 1
+ echo 'configure: failed program was:'
+ sed 's/^/| /' conftest.c
+ rm -f core conftest.err conftest.o conftest.c
++ expr '*' 2
expr: syntax error
+ n=
+ true
==============================================

Best,
v.

Discussion

  • Sam Steingold
    Sam Steingold
    2008-03-31

    Logged In: YES
    user_id=5735
    Originator: NO

    I think you need to figure out why the compilation fails for all values of n.

     
  • Logged In: YES
    user_id=1804953
    Originator: YES

    sorry for not providing this information in the beginning.

    the portion of config.log with one of errors is:

    =========================================================
    configure:53764: i586-mingw32msvc-gcc -c -g -O2 -I/home/vvv/src/clisp/clisp-tools/include conftest.c >&5
    conftest.c: In function 'main':
    conftest.c:145: error: expected expression before 'struct'
    configure:53770: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    | #define PACKAGE_NAME "GNU CLISP"
    | #define PACKAGE_TARNAME "clisp"
    | #define PACKAGE_VERSION "2.45 (2008-04-04)"
    | #define PACKAGE_STRING "GNU CLISP 2.45 (2008-04-04)"
    | #define PACKAGE_BUGREPORT "http://clisp.cons.org/"
    | #define PACKAGE "clisp"
    | #define VERSION "2.45 (2008-04-04)"
    | #ifndef __i386__
    | #define __i386__ 1
    | #endif
    | #define _GNU_SOURCE 1
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_TYPES_H 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_STRING_H 1
    | #define HAVE_MEMORY_H 1
    | #define HAVE_STRINGS_H 1
    | #define HAVE_INTTYPES_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_UNISTD_H 1
    | #define __EXTENSIONS__ 1
    | #define _ALL_SOURCE 1
    | #define _GNU_SOURCE 1
    | #define _POSIX_PTHREAD_SEMANTICS 1
    | #define _TANDEM_SOURCE 1
    | #define ASM_UNDERSCORE
    | #define HAVE_ALLOCA 1
    | #define HAVE_MBSTATE_T 1
    | #define HAVE_BTOWC 1
    | #define HAVE_ISBLANK 1
    | #define HAVE_ISWCTYPE 1
    | #define HAVE_MBSRTOWCS 1
    | #define HAVE_WMEMCHR 1
    | #define HAVE_WMEMCPY 1
    | #define HAVE_MBRTOWC 1
    | #define HAVE_WCRTOMB 1
    | #define HAVE_WCSCOLL 1
    | #define HAVE_ISWCNTRL 1
    | #define HAVE_WCTYPE_H 1
    | #define HAVE_LOCALE_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_WCHAR_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_UNISTD_H 1
    | #define HAVE_DECL_GETC_UNLOCKED 0
    | #define restrict __restrict
    | #define HAVE__BOOL 1
    | #define HAVE_STDBOOL_H 1
    | #define HAVE_LONG_LONG_INT 1
    | #define HAVE_UNSIGNED_LONG_LONG_INT 1
    | #define HAVE_INCLUDE_NEXT 1
    | #define HAVE_WINT_T 1
    | #define HAVE_DECL_ISBLANK 1
    | #define fnmatch gnu_fnmatch
    | #define LINK_FOLLOWS_SYMLINKS 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_MALLOC 0
    | #define malloc rpl_malloc
    | #define GNULIB_MALLOC_GNU 1
    | #define _REGEX_LARGE_OFFSETS 1
    | #define re_syntax_options rpl_re_syntax_options
    | #define re_set_syntax rpl_re_set_syntax
    | #define re_compile_pattern rpl_re_compile_pattern
    | #define re_compile_fastmap rpl_re_compile_fastmap
    | #define re_search rpl_re_search
    | #define re_search_2 rpl_re_search_2
    | #define re_match rpl_re_match
    | #define re_match_2 rpl_re_match_2
    | #define re_set_registers rpl_re_set_registers
    | #define re_comp rpl_re_comp
    | #define re_exec rpl_re_exec
    | #define regcomp rpl_regcomp
    | #define regexec rpl_regexec
    | #define regerror rpl_regerror
    | #define regfree rpl_regfree
    | #define HAVE_DECL_ISBLANK 1
    | #define HAVE_SIGSEGV 1
    | #define HAVE_AVCALL_H 1
    | #define HAVE_CALLBACK_H 1
    | #define return_void return
    | #define HAVE_LONG_LONG_INT 1
    | #define STDC_HEADERS 1
    | #define HAVE_UNISTD_H 1
    | #define HAVE_SYS_FILE_H 1
    | #define HAVE_OFFSETOF
    | #define HAVE_SYS_FILE_H 1
    | #define HAVE_SYS_FILE_H 1
    | #define DIRENT
    | #define CADDR_T void*
    | #define CLISP_SOCKLEN_T int
    | #define SIZEOF_OFF_T 4
    | #define SIZEOF_STRUCT_TIMEVAL 8
    | #define HAVE_STRUCT_DIRENT_D_NAMLEN 1
    | #define HAVE_ALLOCA 1
    | #define RETSIGTYPE void
    | #define SIGNAL_NEED_REINSTALL
    | #define HAVE_RAISE
    | #define RETABORTTYPE void
    | #define ABORT_VOLATILE
    | #define HAVE_PERROR_DECL
    | #define HAVE_STRERROR 1
    | #define HAVE_MEMSET 1
    | #define HAVE_FTIME 1
    | #define HAVE_GETCWD 1
    | #define HAVE_PUTENV 1
    | #define HAVE_DECL_ENVIRON 1
    | #define vfork fork
    | #define PID_T pid_t
    | #define TIME_WITH_SYS_TIME 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STRUCT_STAT_ST_RDEV 1
    | #define SIZEOF_INO_T 2
    | #define SIZEOF_DEV_T 4
    | #define ELOOP_VALUE ELOOP
    | #define RETCLOSEDIRTYPE int
    | #define VOID_CLOSEDIR
    | #define HAVE_GETTIMEOFDAY 1
    | #define GETTIMEOFDAY_TZP_T void *
    | #define CODE_ADDRESS_RANGE 0UL
    | #define MALLOC_ADDRESS_RANGE 0UL
    | #define SHLIB_ADDRESS_RANGE 0UL
    | #define STACK_ADDRESS_RANGE ~0UL
    | #define HAVE_GETPAGESIZE
    | #define RETGETPAGESIZETYPE int
    | #define HAVE_MPROTECT 1
    | #define HAVE_LONG_DOUBLE 1
    | /* end confdefs.h. */
    |
    | #ifdef __cplusplus
    | # ifdef __GNUC__
    | # define alignof(type) __alignof__ (type)
    | # else
    | template <class type> struct alignof_helper { char slot1; type slot2; };
    | # define alignof(type) offsetof (alignof_helper<type>, slot2)
    | # endif
    | #else
    | # define alignof(type) offsetof (struct { char slot1; type slot2; }, slot2)
    | #endif
    |
    | int
    | main ()
    | {
    | typedef int verify[2*(alignof(char) == 32) - 1];
    | ;
    | return 0;
    | }
    =========================================================

    and if i make a preprocessed file (using -E option), here is the "meat":

    $ cat conftest.c
    int
    main ()
    {
    typedef int verify[2*(offsetof (struct { char slot1; char slot2; }, slot2) == 32) - 1];
    ;
    return 0;
    }
    $ i586-mingw32msvc-gcc -c /tmp/conftest.c
    /tmp/conftest.c: In function ‘main’:
    /tmp/conftest.c:4: error: expected expression before ‘struct’

    BTW, i've read in the clisp mailing list that the cross-compile mode was considered at some point as non-supported.
    is it supposed to be supported now? i.e. is it worth fixing bugs related to cross-compiling?

     
  • Sam Steingold
    Sam Steingold
    2008-03-31

    Logged In: YES
    user_id=5735
    Originator: NO

    the only cross-compiling that was dropped was loading clisp compiler.lisp into a non-clisp CL implementation and compiling clisp lisp files with it.

     
  • Sam Steingold
    Sam Steingold
    2008-03-31

    Logged In: YES
    user_id=5735
    Originator: NO

    the error message appears to indicate a problem with the offsetof/alignof definition for your compiler.
    you need to figure out what the right definition is and why this breaks only at cross-compiling.

     
  • Logged In: YES
    user_id=1804953
    Originator: YES

    i get exactly the same diagnostic message when running a regular gcc compiler on that test file:

    int
    main ()
    {
    typedef int verify[2*(offsetof (struct { char slot1; char slot2; }, slot2) == 32) - 1];
    ;
    return 0;
    }

    does your gcc compile this?

     
  • Sam Steingold
    Sam Steingold
    2008-03-31

    Logged In: YES
    user_id=5735
    Originator: NO

    thank you for your bug report.
    the bug has been fixed in the CVS tree.
    you can either wait for the next release (recommended)
    or check out the current CVS tree (see http://clisp.cons.org\)
    and build CLISP from the sources (be advised that between
    releases the CVS tree is very unstable and may not even build
    on your platform).

     
  • Sam Steingold
    Sam Steingold
    2008-03-31

    Logged In: YES
    user_id=5735
    Originator: NO

    the fix is to #include <stddef.h>

     
  • Sam Steingold
    Sam Steingold
    2008-03-31

    • assigned_to: haible --> sds
    • status: open --> closed-fixed
     
  • Logged In: YES
    user_id=1804953
    Originator: YES

    thank you, now i get further, many alignof tests are performed, until we get to test
    void (*)(void), where i get the same infinite loop, with the following in config.log:

    [same diagnostic for cross-compiler and native gcc]

    configure:59413: i586-mingw32msvc-gcc -c -g -O2 -I/home/vvv/src/clisp/clisp-tools/include conftest.c >&5
    conftest.c: In function 'main':
    conftest.c:148: error: expected identifier or '(' before ')' token
    conftest.c:148: warning: no semicolon at end of struct or union
    conftest.c:148: error: 'struct <anonymous>' has no member named 'slot2'
    configure:59419: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    | #define PACKAGE_NAME "GNU CLISP"
    | #define PACKAGE_TARNAME "clisp"
    | #define PACKAGE_VERSION "2.45 (2008-04-04)"
    | #define PACKAGE_STRING "GNU CLISP 2.45 (2008-04-04)"
    | #define PACKAGE_BUGREPORT "http://clisp.cons.org/"
    | #define PACKAGE "clisp"
    | #define VERSION "2.45 (2008-04-04)"
    | #ifndef __i386__
    | #define __i386__ 1
    | #endif
    | #define _GNU_SOURCE 1
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_TYPES_H 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_STRING_H 1
    | #define HAVE_MEMORY_H 1
    | #define HAVE_STRINGS_H 1
    | #define HAVE_INTTYPES_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_UNISTD_H 1
    | #define __EXTENSIONS__ 1
    | #define _ALL_SOURCE 1
    | #define _GNU_SOURCE 1
    | #define _POSIX_PTHREAD_SEMANTICS 1
    | #define _TANDEM_SOURCE 1
    | #define ASM_UNDERSCORE
    | #define HAVE_ALLOCA 1
    | #define HAVE_MBSTATE_T 1
    | #define HAVE_BTOWC 1
    | #define HAVE_ISBLANK 1
    | #define HAVE_ISWCTYPE 1
    | #define HAVE_MBSRTOWCS 1
    | #define HAVE_WMEMCHR 1
    | #define HAVE_WMEMCPY 1
    | #define HAVE_MBRTOWC 1
    | #define HAVE_WCRTOMB 1
    | #define HAVE_WCSCOLL 1
    | #define HAVE_ISWCNTRL 1
    | #define HAVE_WCTYPE_H 1
    | #define HAVE_LOCALE_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_WCHAR_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_UNISTD_H 1
    | #define HAVE_DECL_GETC_UNLOCKED 0
    | #define restrict __restrict
    | #define HAVE__BOOL 1
    | #define HAVE_STDBOOL_H 1
    | #define HAVE_LONG_LONG_INT 1
    | #define HAVE_UNSIGNED_LONG_LONG_INT 1
    | #define HAVE_INCLUDE_NEXT 1
    | #define HAVE_WINT_T 1
    | #define HAVE_DECL_ISBLANK 1
    | #define fnmatch gnu_fnmatch
    | #define LINK_FOLLOWS_SYMLINKS 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_MALLOC 0
    | #define malloc rpl_malloc
    | #define GNULIB_MALLOC_GNU 1
    | #define _REGEX_LARGE_OFFSETS 1
    | #define re_syntax_options rpl_re_syntax_options
    | #define re_set_syntax rpl_re_set_syntax
    | #define re_compile_pattern rpl_re_compile_pattern
    | #define re_compile_fastmap rpl_re_compile_fastmap
    | #define re_search rpl_re_search
    | #define re_search_2 rpl_re_search_2
    | #define re_match rpl_re_match
    | #define re_match_2 rpl_re_match_2
    | #define re_set_registers rpl_re_set_registers
    | #define re_comp rpl_re_comp
    | #define re_exec rpl_re_exec
    | #define regcomp rpl_regcomp
    | #define regexec rpl_regexec
    | #define regerror rpl_regerror
    | #define regfree rpl_regfree
    | #define HAVE_DECL_ISBLANK 1
    | #define HAVE_SIGSEGV 1
    | #define HAVE_AVCALL_H 1
    | #define HAVE_CALLBACK_H 1
    | #define return_void return
    | #define HAVE_LONG_LONG_INT 1
    | #define STDC_HEADERS 1
    | #define HAVE_UNISTD_H 1
    | #define HAVE_SYS_FILE_H 1
    | #define HAVE_OFFSETOF
    | #define HAVE_SYS_FILE_H 1
    | #define HAVE_SYS_FILE_H 1
    | #define DIRENT
    | #define CADDR_T void*
    | #define CLISP_SOCKLEN_T int
    | #define SIZEOF_OFF_T 4
    | #define SIZEOF_STRUCT_TIMEVAL 8
    | #define HAVE_STRUCT_DIRENT_D_NAMLEN 1
    | #define HAVE_ALLOCA 1
    | #define RETSIGTYPE void
    | #define SIGNAL_NEED_REINSTALL
    | #define HAVE_RAISE
    | #define RETABORTTYPE void
    | #define ABORT_VOLATILE
    | #define HAVE_PERROR_DECL
    | #define HAVE_STRERROR 1
    | #define HAVE_MEMSET 1
    | #define HAVE_FTIME 1
    | #define HAVE_GETCWD 1
    | #define HAVE_PUTENV 1
    | #define HAVE_DECL_ENVIRON 1
    | #define vfork fork
    | #define PID_T pid_t
    | #define TIME_WITH_SYS_TIME 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STRUCT_STAT_ST_RDEV 1
    | #define SIZEOF_INO_T 2
    | #define SIZEOF_DEV_T 4
    | #define ELOOP_VALUE ELOOP
    | #define RETCLOSEDIRTYPE int
    | #define VOID_CLOSEDIR
    | #define HAVE_GETTIMEOFDAY 1
    | #define GETTIMEOFDAY_TZP_T void *
    | #define CODE_ADDRESS_RANGE 0UL
    | #define MALLOC_ADDRESS_RANGE 0UL
    | #define SHLIB_ADDRESS_RANGE 0UL
    | #define STACK_ADDRESS_RANGE ~0UL
    | #define HAVE_GETPAGESIZE
    | #define RETGETPAGESIZETYPE int
    | #define HAVE_MPROTECT 1
    | #define HAVE_LONG_DOUBLE 1
    | /* end confdefs.h. */
    |
    | #ifdef HAVE_OFFSETOF
    | # include <stddef.h>
    | #endif
    | #ifdef __cplusplus
    | # ifdef __GNUC__
    | # define alignof(type) __alignof__ (type)
    | # else
    | template <class type> struct alignof_helper { char slot1; type slot2; };
    | # define alignof(type) offsetof (alignof_helper<type>, slot2)
    | # endif
    | #else
    | # define alignof(type) offsetof (struct { char slot1; type slot2; }, slot2)
    | #endif
    |
    | int
    | main ()
    | {
    | typedef int verify[2*(alignof(void (*)(void)) == 256) - 1];
    | ;
    | return 0;
    | }

     
    • status: closed-fixed --> open-fixed
     
  • Logged In: YES
    user_id=1804953
    Originator: YES

    pre-processed code looks like:

    =====================================
    typedef int ptrdiff_t;
    typedef unsigned int size_t;
    typedef short unsigned int wchar_t;
    int
    main ()
    {
    typedef int verify[2*(__builtin_offsetof (struct { char slot1; void (*)(void) slot2; }, slot2) == 256) - 1];
    ;
    return 0;
    }
    =====================================

    which has syntax error because of void (*)(void) slot2;

    and this test loops infinitely with increasing n,
    because on each n there's an error

     
  • Sam Steingold
    Sam Steingold
    2008-03-31

    Logged In: YES
    user_id=5735
    Originator: NO

    I disabled the corresponding code because it is never used

     
  • Sam Steingold
    Sam Steingold
    2008-03-31

    • status: open-fixed --> closed-fixed