Subject: bug#10742: further information

From: [email-masked] (Ludovic Courtès)
Date: Thu, 16 Feb 2012 23:12:18 +0100

Hi Alírio,

Sorry for the delay!

Alírio Eyng <[email-masked]> skribis:

> bash-4.1# meta/guile -c '(setlocale LC_ALL "") (pk (fluid-ref %default-port-encoding))'
> Backtrace:
> In ice-9/boot-9.scm:
>  149: 2 [catch #t #<catch-closure 81d9580> ...]
>  157: 1 [#<procedure 80c92a8 ()>]
> In unknown file:
>    ?: 0 [catch-closure]
>
> ERROR: In procedure catch-closure:
> ERROR: Throw to key `decoding-error' with args `("scm_from_stringn" "input locale conversion error" 22 #vu8(40 115 101 116 108 111 99 97 108 101 32 76 67 95 65 76 76 32 34 34 41 32 40 112 107 32 40 102 108 117 105 100 45 114 101 102 32 37 100 101 102 97 117 108 116 45 112 111 114 116 45 101 110 99 111 100 105 110 103 41 41))'.

Hmm.  22 here is EINVAL, returned by u32_conv_from_encoding, and
probably coming from iconv_open(3) or iconv(3).

Can you try this patch and tell us what gets written?

diff --git a/libguile/script.c b/libguile/script.c
index 83daf8a..3d22923 100644
--- a/libguile/script.c
+++ b/libguile/script.c
@@ -388,6 +388,7 @@ locale_arguments_to_string_list (int argc, char **const argv)
   const char *encoding;
 
   encoding = environ_locale_charset ();
+  printf ("encoding: `%s'\n", encoding);
   for (i = argc - 1, lst = SCM_EOL;
        i >= 0;
        i--)

Can you show the output of ‘ldd --version’?

Finally, can you try the program below?  Compile it as indicated in the
file, and run it as:

  $ LD_PRELOAD=iconv.so guile -c 1

It will print the series of iconv_open(3) calls that are made, and
hopefully the one that fails.

Thanks,
Ludo’.

/* Display looked up environment variables.

   Compile as shown at the bottom of this file.

   Run with:

     $ LD_PRELOAD=./iconv_open.so some-program

   Written by Ludovic Courtès <ludo-mXXj517/[email-masked]>.  Hereby placed under the
   LGPLv3+.
 */

#include <stdio.h>
#include <gnu/lib-names.h>
#include <dlfcn.h>
#include <errno.h>

static void *glibc;
static char * (*glibc_iconv_open) (const char *, const char *);

static void load_glibc (void) __attribute__ ((__constructor__));

static void
load_glibc (void)
{
  glibc = dlopen (LIBC_SO, RTLD_LAZY);
  glibc_iconv_open = dlsym (glibc, "iconv_open");
}

char *
iconv_open (const char *to, const char *from)
{
  char *result;

  errno = 0;
  result = glibc_iconv_open (to, from);

  printf ("iconv_open (\"%s\", \"%s\") = %p (%m)\n",
	  to, from, result);

  return result;
}

/*
   Local Variables:
   compile-command: "gcc -Wall -shared -fPIC -o iconv.so iconv.c"
   End:
 */