develooper Front page | perl.perl5.porters | Postings from January 2014

[perl #121080] blead setlocale broken on VMS

Thread Next
From:
Craig A . Berry
Date:
January 25, 2014 03:58
Subject:
[perl #121080] blead setlocale broken on VMS
Message ID:
rt-4.0.18-4021-1390622310-475.121080-75-0@perl.org
# New Ticket Created by  Craig A. Berry 
# Please include the string:  [perl #121080]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=121080 >


As of v5.19.8-106-g6fbeaf2, locale.t fails on VMS like so:

$ perl t/run/locale.t
1..16
ok 1 - no locales where LC_NUMERIC breaks
ok 2 - LC_NUMERIC without environment nor setlocale() has no effect in any locale
# using the 'DA_DK_ISO8859-1-EURO.LOCALE' locale for LC_NUMERIC tests
ok 3 - format() does not look at LC_NUMERIC without 'use locale'
<snip>
ok 11 - No compile error on v-strings when setting the locale to non-dot radix at compile time when default environment has non-dot radix
not ok 12 - Passed in LC_NUMERIC is valid at compilation time
# Failed test 12 - Passed in LC_NUMERIC is valid at compilation time at ./test.pl line 954
#      got "#\005_DSA0          308870009500512"
# expected "DA_DK_ISO8859-1-EURO.LOCALE"
# PROG:
# 	    use POSIX qw(locale_h);
#
#             BEGIN { print setlocale(LC_NUMERIC), "
# "; };
# STATUS: 0
ok 13 - Radix print properly in locale scope, and without
ok 14 - Can do math when radix is a comma
ok 15 - POSIX::strtod() uses underlying locale
ok 16 - /il matching of [bracketed] doesn't skip POSIX class if fails individ char

This boils down to simply:

$ define LC_NUMERIC DA_DK_ISO8859-1-EURO.LOCALE
$ perl -e "use POSIX qw(locale_h); print setlocale(LC_NUMERIC);"
#_DSA0          308870009500512

and the same with any other valid locale in the LC_NUMERIC environment entry.  I don't think we were running this test before a5dfa8d3f00186c1b4decd582515924aef2ebbd6, but there's still something new and wrong since 5.18.2, which does this:

$ perl -e "use POSIX qw(locale_h); print setlocale(LC_NUMERIC);"
C

which may or may not be correct, but at least it's returning a real locale, not garbage.

It so happens that _DSA0 is the device name of my system disk.  It sure looks as though we have corrupted the data setlocale looks at so it is off in the weeds looking at things it shouldn't.

I thought it might be a CRTL bug so tried to reproduce the problem with this minimal C program:

$ type setlocale_bug.c
#include <errno.h>
#include <stdio.h>
#include <locale.h>

main()
{
    char *ret_str;

    errno = 0;
    ret_str = (char *) setlocale(LC_NUMERIC, NULL);

    if (ret_str == NULL)
        perror("setlocale error");
    else
        printf("Fetched locale '%s' using LC_NUMERIC\n", ret_str);
}

but that also always returns the "C" locale regardless of what's defined (or not defined) for LC_NUMERIC.  In other words, this does the same as what Perl 5.18.2 does.  It also always returns "C" on Darwin regardless of the LC_NUMERIC setting, so I question the expectation of locale.t that setlocale(LC_NUMERIC, NULL) will return the value of LC_NUMERIC from the environment.


$ perl -V
Summary of my perl5 (revision 5 version 19 subversion 9) configuration:
  Snapshot of: 6fbeaf2cefaf9e56416f1453f4b8bac8f1f3f46c
  Platform:
    osname=VMS, osvers=V8.4, archname=VMS_IA64-thread-multi
    uname='VMS alma V8.4 HP rx2600  (1.50GHz/6.0MB)'
    config_args='-"Dusedevel" -"DDEBUGGING" -"Dusethreads" -"Dusevmsdebug" -"des"'
    hint=none, useposix=false, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=undef, bincompat5005=undef
  Compiler:
    cc='CC/DECC', ccflags ='/Include=[]/Standard=Relaxed_ANSI/Prefix=All/Obj=.obj /NOANSI_ALIAS/float=ieee/ieee=denorm/NAMES=(SHORTENED)/Define=_USE_STD_STAT=1',
    optimize='/List/Debug/NoOpt',
    cppflags='undef'
    ccversion='70390020', gccversion='', gccosandvers='undef'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='Link/nodebug', ldflags ='/Debug/Trace/Map'
    libpth=/sys$share /sys$library
    libs=
    perllibs=
    libc=(DECCRTL), so=exe, useshrplib=true, libperl=undef
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_vms.xs, dlext=exe, d_dlsymun=undef, ccdlflags=''
    cccdlflags='', lddlflags='/Share'


Characteristics of this PERLSHR image:
  Compile-time options: DEBUGGING HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY
                        PERLIO_LAYERS PERL_DONT_CREATE_GVSV
                        PERL_EXTERNAL_GLOB PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        PERL_TRACK_MEMPOOL USE_IEEE USE_ITHREADS
                        USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE
                        USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO
                        USE_PERL_ATOF USE_REENTRANT_API VMS_DO_SOCKETS
                        VMS_SHORTEN_LONG_SYMBOLS
  Built under VMS
  Compiled at Jan 24 2014 18:21:39
  %ENV:
    PERLSHR="perl_root:[000000]perlshr.exe"
    PERL_ROOT="DSA0:[craig.blead.]"
  @INC:
    /perl_root/lib/site_perl/VMS_IA64-thread-multi
    /perl_root/lib/site_perl
    /perl_root/lib/VMS_IA64-thread-multi/5_19_9
    /perl_root/lib
    .



________________________________________
Craig A. Berry
mailto:craigberry@mac.com

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About