Hi,

I have attached a test-suite.log with some test failures I found while
testing the latest Coreutils snapshot on CheriBSD.

At least a few of these seem to have been cause by a bug that I just
reported here [1].

The issue is that the mbrtowc implementation for GB18030 calls
strlen. This means that the third size argument is not respected. This
is obviously incorrect, since most (all?) implementations of btowc just
call mbrtowc with a single character.

Here is a test program:

    #include <stdio.h>
    #include <locale.h>
    #include <wchar.h>
    int
    main (void)
    {
      setlocale (LC_ALL, "zh_CN.GB18030");
      return ! (btowc ('A') == L'A');
    }

Here is the result on GNU/Linux:

    $ ./a.out
    $ echo $?
    0

Here is the result on CheriBSD:

    $ ./a.out
    In-address space security exception (core dumped)

And here is the backtrace:

    (gdb) bt
    #0  strlen (str=0xfffffff7feac [rwRW,0xfffffff7feac-0xfffffff7fead] "A@", 
<incomplete sequence \334>)
        at 
/local/scratch/jenkins/workspace/CheriBSD-pipeline_releng_25.03@2/cheribsd/lib/libc/string/strlen.c:143
    #1  0x00000000402935d4 in _GB18030_mbrtowc (pwc=0xfffffff7fea8 
[rwRW,0xfffffff7fea8-0xfffffff7feac] L"\x7210d070\xdc5f4041", 
        s=0xfffffff7feac [rwRW,0xfffffff7feac-0xfffffff7fead] "A@", <incomplete 
sequence \334>, n=1, ps=0xfffffff7feb0 [rwRW,0xfffffff7feb0-0xfffffff7ff30])
        at 
/local/scratch/jenkins/workspace/CheriBSD-pipeline_releng_25.03@2/cheribsd/lib/libc/locale/gb18030.c:125
    #2  0x0000000040291f48 in btowc_l (l=<optimized out>, c=<optimized out>) at 
/local/scratch/jenkins/workspace/CheriBSD-pipeline_releng_25.03@2/cheribsd/lib/libc/locale/btowc.c:55
    #3  btowc (c=<optimized out>) at 
/local/scratch/jenkins/workspace/CheriBSD-pipeline_releng_25.03@2/cheribsd/lib/libc/locale/btowc.c:62
    #4  0x0000000000110820 in main ()

Bruno, do you think it is worth fixing this in Gnulib, or should we just
document it and move on? I assume that only a small subset of CheriBSD
users, which is already a small set, use GB18030.

Collin

[1] https://github.com/CTSRD-CHERI/cheribsd/issues/2455

=====================================
   dummy 0: gltests/test-suite.log
=====================================

# TOTAL: 231
# PASS:  182
# SKIP:  40
# XFAIL: 0
# FAIL:  9
# XPASS: 0
# ERROR: 0

System information (uname -a): FreeBSD 15.0-CURRENT FreeBSD 15.0-CURRENT #0 
releng/25.03-2339ee891fe2: Thu Apr 3 18:44:17 UTC 2025 
jenkins@ctsrd-build-linux-k1:/local/scratch/jenkins/workspace/CheriBSD-pipeline_releng_25.03@2/cheribsd-morello-purecap-build/local/scratch/jenkins/workspace/CheriBSD-pipeline_releng_25.03@2/cheribsd/arm64.aarch64c/sys/GENERIC-MORELLO-PURECAP
Distribution information (/etc/os-release):
NAME=CheriBSD
VERSION="15.0-CURRENT"
VERSION_ID="15.0"
ID=cheribsd
ID_LIKE=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="CheriBSD 15.0-CURRENT"
CPE_NAME="cpe:/o:freebsd:freebsd:15.0"

.. contents:: :depth: 2

FAIL: test-c32rtomb.sh
======================

In-address space security exception (core dumped)
FAIL test-c32rtomb.sh (exit status: 1)

FAIL: test-mbrlen-5.sh
======================

test-mbrlen.c:55: assertion 'ret == 0' failed
Abort trap (core dumped)
FAIL test-mbrlen-5.sh (exit status: 134)

FAIL: test-mbrtoc32-5.sh
========================

test-mbrtoc32.c:60: assertion 'ret == 0' failed
Abort trap (core dumped)
FAIL test-mbrtoc32-5.sh (exit status: 134)

FAIL: test-mbrtowc-5.sh
=======================

test-mbrtowc.c:59: assertion 'ret == 0' failed
Abort trap (core dumped)
FAIL test-mbrtowc-5.sh (exit status: 134)

FAIL: test-mbsrtoc32s-5.sh
==========================

test-mbsrtoc32s.c:72: assertion 'wc == 0' failed
Abort trap (core dumped)
FAIL test-mbsrtoc32s-5.sh (exit status: 134)

FAIL: test-mbsrtowcs-5.sh
=========================

test-mbsrtowcs.c:71: assertion 'wc == 0' failed
Abort trap (core dumped)
FAIL test-mbsrtowcs-5.sh (exit status: 134)

FAIL: test-mcel-5.sh
====================

test-mcel.c:40: assertion '!c.err == (n <= MB_LEN_MAX)' failed
Abort trap (core dumped)
FAIL test-mcel-5.sh (exit status: 134)

FAIL: test-nl_langinfo-mt
=========================

FAIL test-nl_langinfo-mt (exit status: 134)

FAIL: test-wcrtomb.sh
=====================

In-address space security exception (core dumped)
FAIL test-wcrtomb.sh (exit status: 1)

Reply via email to