Bug 29202 - [gdb/rust] Running selftest rust-lex. Self test failed: Converting character sets: Invalid argument.
Summary: [gdb/rust] Running selftest rust-lex. Self test failed: Converting character ...
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: testsuite (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-31 08:58 UTC by Tom de Vries
Modified: 2022-06-07 12:18 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2022-05-31 08:58:53 UTC
Here ( https://builder.sourceware.org/buildbot/#/builders/98/builds/10 ) we have:
...
Running selftest rust-lex.
Self test failed: Converting character sets: Invalid argument.
...
Ran 147 unit tests, 1 failed
(gdb) PASS: gdb.gdb/unittest.exp: no executable loaded: maintenance selftest, ran some tests
FAIL: gdb.gdb/unittest.exp: no executable loaded: maintenance selftest, failed none
...

I managed to reproduce this in a container helpfully set up by Martin Liška.

The root cause turned out to be this call failing:
...
(gdb) fin
Run till exit from #0  0x00007f0c2e11668e in iconv_open () from /lib64/libc.so.6
iconv_wrapper::iconv_wrapper (from=0x11946e0 "ANSI_X3.4-1968", to=0x96de99 "UTF-32LE", this=<synthetic pointer>) at ../../gdb/charset.c:476
...
because the support for UTF-32LE was not installed.

Adding the package glibc-locale made the test pass.
Comment 1 Tom de Vries 2022-05-31 09:03:11 UTC
IWBN if for instance the test-case failed in a more verbose way, as in:
...
cannot convert from "ANSI_X3.4-1968" to "UTF-32LE"
...

Or perhaps skip the test as unsupported instead of failing.
Comment 2 Tom de Vries 2022-05-31 09:24:04 UTC
Hmm, in ada-lang.c we have:
...
      try
        {
          convert_between_encodings
            (host_charset (), HOST_UTF32,
             (const gdb_byte *) name.data (),
             name.length (), 1,
             &storage, translit_none);
        }
      catch (const gdb_exception &)
        {
          if (throw_on_error)
            throw;

          static bool warned = false;

          /* Converting to UTF-32 shouldn't fail, so if it doesn't, we                        
             might like to know why.  */
          if (!warned)
            {
            {
              warned = true;
              warning (_("could not convert '%s' from the host encoding (%s) to UTF-32.\n"
                         "This normally should not happen, please file a bug report."),
                       gdb::to_string (name).c_str (), host_charset ());
            }
...

I suppose we could use something similar.
Comment 3 Tom Tromey 2022-06-01 15:44:36 UTC
Catching the error in the unit test seems reasonable,
though on the other hand this is a kind of host configuration error.
Comment 4 Tom de Vries 2022-06-03 10:39:20 UTC
This is still failing in the latest build ( https://builder.sourceware.org/buildbot/#/builders/98/builds/78 ).

Will the glibc-locale package be installed?
Comment 5 Mark Wielaard 2022-06-03 10:53:48 UTC
(In reply to Tom de Vries from comment #4)
> This is still failing in the latest build (
> https://builder.sourceware.org/buildbot/#/builders/98/builds/78 ).
> 
> Will the glibc-locale package be installed?

I will post a patch for the Container files to the buildbot mailinglist:
https://sourceware.org/mailman/listinfo/buildbot
Comment 8 Tom de Vries 2022-06-07 12:18:17 UTC
Patches submitted:
- [PATCH][gdb] Improve "Converting character sets: Invalid argument"
  https://sourceware.org/pipermail/gdb-patches/2022-June/189864.html
- [PATCH][gdb] Handle NOT_SUPPORTED_ERROR in rust-lex selftest
  https://sourceware.org/pipermail/gdb-patches/2022-June/189865.html