bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: long long double on interix


From: Markus Duft
Subject: Re: long long double on interix
Date: Thu, 08 Sep 2011 08:09:50 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110706 Lightning/1.0b3pre Thunderbird/3.1.10

On 06/10/11 11:37, Bruno Haible wrote:
> Hi,
> 
> Markus Duft wrote:
>> long long double is broken.
> 
> You surely mean "long double"? There is no such type as "long long double"
> in C.
> 
>> this bites me in the gnulib vasnprintf implementation, which calls snprintf
>> from libc which immediately crashes ... :(  
> 
> gnulib and coreutils code now assume that the 'long double' type exists
> and basically works at the compiler level (variable assignment, parameter
> passing, return value).
> 
> Setting gt_cv_c_long_double=no therefore has no effect any more.
> 
> You need to find out what is wrong about that type on your platform. If
> you're lucky, it's only some library functions (like snprintf) which don't
> support it.
> 
> Your best starting point should be to create a gnulib testdir
>   $ ./gnulib-tool --create-testdir --dir=/tmp/testdir --with-tests \
>     acosl asinl atanl ceill cosl c-strtold expl float floorl fpucw frexpl \
>     frexpl-nolibm ftoastr human isfinite isinf isnanl isnanl-nolibm ldexpl \
>     ldtoastr logl math printf-frexpl roundl signbit sinl sqrtl tanl truncl \
>     vasnprintf
> and test that package on your platform. From the list of tests that fail,
> you should be able to investigate the precise problems with 'long double'.

sorry to revive this old thread. just got some minutes to give the tests a go :)

while building the above from current git sources, i get this on interix:

gcc -DHAVE_CONFIG_H -I.  -DGNULIB_STRICT_CHECKING=1 -I. -I. -I.. -I./.. 
-I../gllib -I./../gllib   -g -O2 -MT test-sys_stat.o -MD -MP -MF 
.deps/test-sys_stat.Tpo -c -o test-sys_stat.o test-sys_stat.c
test-sys_stat.c:85: error: negative width in bit-field 
'_gl_verify_error_if_negative'
make[4]: *** [test-sys_stat.o] Error 1

from /usr/include/sys/stat.h:
   73 #define S_IFSOCK    0x0C000     /* socket */
  111 #define S_ISSOCK(m) ( ((m) & S_IFMT) == S_IFSOCK )
  114 /*
  115  * note: using POSIX.1gD6.5 definition 
  116  *       (eg. one or both S_ISFIFO or S_ISCHR should return TRUE for a 
socket)
  117  */
  118 #define S_ISCHR(m) (  (((m) & S_IFMT) == S_IFCHR)   \
  119             || (((m) & S_IFMT) == S_IFSOCK) )

i commented this line for now, as it seems unrelated to what i want to actually 
check, and the build went through now.

as for the long double tests, i get this:

PASS: test-acosl
PASS: test-alloca-opt
PASS: test-argmatch
PASS: test-asinl
PASS: test-atanl
PASS: test-binary-io.sh
PASS: test-btowc1.sh
Skipping test: no french Unicode locale is installed
SKIP: test-btowc2.sh
test-ceill.c:54: assertion failed
Abort (core dumped) 
FAIL: test-ceill
PASS: test-cosl
PASS: test-dup2
PASS: test-environ
PASS: test-errno
PASS: test-expl
PASS: test-fcntl-h
PASS: test-float
PASS: test-floor1
PASS: test-floor2
test-floorl.c:53: assertion failed
Abort (core dumped) 
FAIL: test-floorl
PASS: test-frexpl-nolibm
PASS: test-frexpl
test-getcwd-lgpl.c:95: assertion failed
Abort (core dumped) 
FAIL: test-getcwd-lgpl
PASS: test-getopt
PASS: test-ignore-value
PASS: test-intprops
PASS: test-inttypes
PASS: test-isfinite
PASS: test-isinf
PASS: test-isnand-nolibm
PASS: test-isnanf-nolibm
PASS: test-isnanl-nolibm
PASS: test-isnanl
PASS: test-ldexpl
PASS: test-locale
PASS: test-localename
Starting test_lock ... OK
Starting test_rwlock ... OK
Starting test_recursive_lock ... OK
Starting test_once ... OK
PASS: test-lock
PASS: test-logl
PASS: test-lstat
PASS: test-malloca
FAIL: test-math
PASS: test-mbrtowc1.sh
Skipping test: no french Unicode locale is installed
SKIP: test-mbrtowc2.sh
PASS: test-mbrtowc3.sh
Skipping test: no transitional chinese locale is installed
SKIP: test-mbrtowc4.sh
Skipping test: not a native Windows system
SKIP: test-mbrtowc-w32-1.sh
Skipping test: not a native Windows system
SKIP: test-mbrtowc-w32-2.sh
Skipping test: not a native Windows system
SKIP: test-mbrtowc-w32-3.sh
Skipping test: not a native Windows system
SKIP: test-mbrtowc-w32-4.sh
Skipping test: not a native Windows system
SKIP: test-mbrtowc-w32-5.sh
Skipping test: no french Unicode locale is installed
SKIP: test-mbsinit.sh
PASS: test-memchr
PASS: test-open
PASS: test-printf-frexpl
PASS: test-quotearg-simple
PASS: test-roundl
PASS: test-setenv
PASS: test-setlocale1.sh
PASS: test-setlocale2.sh
PASS: test-signbit
PASS: test-sinl
PASS: test-sqrt
PASS: test-sqrtl
PASS: test-stat
PASS: test-stdbool
PASS: test-stddef
PASS: test-stdint
PASS: test-stdio
PASS: test-stdlib
PASS: test-strerror
PASS: test-string
PASS: test-strtoumax
PASS: test-symlink
PASS: test-sys_stat
PASS: test-tanl
PASS: test-thread_self
PASS: test-thread_create
PASS: test-time
PASS: test-truncl
PASS: test-unistd
test-unsetenv.c:41: assertion failed
Abort (core dumped) 
FAIL: test-unsetenv
PASS: test-vasnprintf
PASS: test-verify
PASS: test-verify.sh
PASS: test-wchar
PASS: test-wcrtomb.sh
Skipping test: not a native Windows system
SKIP: test-wcrtomb-w32-1.sh
Skipping test: not a native Windows system
SKIP: test-wcrtomb-w32-2.sh
Skipping test: not a native Windows system
SKIP: test-wcrtomb-w32-3.sh
Skipping test: not a native Windows system
SKIP: test-wcrtomb-w32-4.sh
Skipping test: not a native Windows system
SKIP: test-wcrtomb-w32-5.sh
PASS: test-wctype-h
PASS: test-xalloc-die.sh
PASS: test-xstrtol.sh
PASS: test-xstrtoumax.sh
=======================
5 of 80 tests failed
(14 tests were not run)
=======================

anything you can read from this?

also i have a small test program i compile with "". a debugging session looks 
like this:

(gdb) r
Starting program: /home/mduft/tmp/testdir/a.out 
warning: "_environ": indirect symbol does not have real one (-1)

warning: "address@hidden": indirect symbol does not have real one (-1)


Breakpoint 1, main () at ../xx.c:6
6       int main(void) {
(gdb) n
7               long double xx = 123.123;
(gdb) 
9               size_t s = sizeof(buf);
(gdb) 
11              printf("%Lf\n", xx);
(gdb) 
-3810145751680160745362806907787881521477030546836359780536688224467492277107480065984104047918732955237976937983629061077913595526415296426558036247825348634974333318571126535253389672692914736009446350412609321095327470752340329355112274757602313234921943990272.000000
13              printf("%s\n", buf);
(gdb) 
-3810145751680160745362806907787881521477030546836359780536688224467492277107480065984104047918732955237976937983629061077913595526415296426558036247825348634974333318571126535253389672692914736009446350412609321095327470752340329355112274757602313234921943990272.000000

15              char* xxx = asnprintf(buf, &s, "%Lf\n", xx);
(gdb) p xx
$1 = 123.123
(gdb) p s
$2 = 1024
(gdb) c 
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x77db71f9 in _s___vfprintf () from /usr/lib/libc.so.5.2
(gdb) bt
#0  0x77db71f9 in _s___vfprintf () from /usr/lib/libc.so.5.2
#1  0x77da7a68 in snprintf () from /usr/lib/libc.so.5.2
#2  0x004021be in vasnprintf (
    resultbuf=0x81fba0 
"-3810145751680160745362806907787881521477030546836359780536688224467492277107480065984104047918732955237976937983629061077913595526415296426558036247825348634974333318571126535253389672692914736009446"...,
 lengthp=0x81fb9c, format=0x407048 "%Lf\n", args=0x81fb7c "") at 
vasnprintf.c:5075
#3  0x00401b9e in asnprintf (
    resultbuf=0x81fba0 
"-3810145751680160745362806907787881521477030546836359780536688224467492277107480065984104047918732955237976937983629061077913595526415296426558036247825348634974333318571126535253389672692914736009446"...,
 lengthp=0x81fb9c, format=0x407048 "%Lf\n") at asnprintf.c:32
#4  0x00401b57 in main () at ../xx.c:15
(gdb) 


i debugged some more, and ended up immediately before the crash with this:

(gdb) p a.arg[0]
$3 = {type = TYPE_LONGDOUBLE, a = {a_schar = 0 '\0', a_uchar = 0 '\0', a_short 
= -6144, a_ushort = 59392, a_int = 584116224, a_uint = 584116224, 
    a_longint = 584116224, a_ulongint = 584116224, a_longlongint = 
-702849772245948416, a_ulonglongint = 17743894301463603200, a_float = 
5.66241525e-18, 
    a_double = -3.8101457516801607e+261, a_longdouble = 123.123, a_char = 
584116224, a_wide_char = 584116224, 
    a_string = 0x22d0e800 <Address 0x22d0e800 out of bounds>, a_wide_string = 
0x22d0e800, a_pointer = 0x22d0e800, 
    a_count_schar_pointer = 0x22d0e800 <Address 0x22d0e800 out of bounds>, 
a_count_short_pointer = 0x22d0e800, a_count_int_pointer = 0x22d0e800, 
    a_count_longint_pointer = 0x22d0e800, a_count_longlongint_pointer = 
0x22d0e800}}

as a_longdouble is 123.123, i think that basic usage of long double is ok, and 
"just" printing functionality in libc is broken. damn. i think i'll be back to 
re-implementing/fixing it in suacomp instead. is there something i can re-use 
in gnulib?

regards, and thanks for the help,
markus

> 
> Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]