procenv cannot handle utf-8 chars when producing XML or JSON output

Bug #1325494 reported by James Hunt on 2014-06-02
This bug affects 1 person
Affects Status Importance Assigned to Milestone
James Hunt

Bug Description

$ src/procenv --locale
  LANG: fr_CA.UTF8
  LC_NAME: en_GB.UTF-8
  LC_TIME: en_GB.UTF-8
$ make check
INFO: Ensure /data/bzr/procenv/trunk/src/procenv runs with no errors
INFO: Ensure --file=<file> works
INFO: Ensure --output=stdout works
INFO: Ensure --output=stderr works
INFO: Ensure --exec works
INFO: Ensure '--format=text' works
INFO: Ensure '--format=crumb' works
INFO: Ensure '--format=xml' works
*** Error in `/data/bzr/procenv/trunk/src/procenv': malloc(): memory corruption: 0x0000000001235c20 ***
FAIL: check_all_args
1 of 3 tests failed
Please report to <email address hidden>
Makefile:476: recipe for target 'check-TESTS' failed
make[2]: *** [check-TESTS] Error 1
make[2]: Leaving directory '/data/bzr/procenv/trunk/src'
Makefile:599: recipe for target 'check-am' failed
make[1]: *** [check-am] Error 2
make[1]: Leaving directory '/data/bzr/procenv/trunk/src'
Makefile:427: recipe for target 'check-recursive' failed
make: *** [check-recursive] Error 1
$ gdb src/procenv ./src/core.24767
GNU gdb (Ubuntu 7.7.1-0ubuntu2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from src/procenv...done.
[New LWP 24767]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/".
Core was generated by `/data/bzr/procenv/trunk/src/procenv --format=xml'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007f70a3eb6f79 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: Aucun fichier ou dossier de ce type.
(gdb) bt
#0 0x00007f70a3eb6f79 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007f70a3eba388 in __GI_abort () at abort.c:89
#2 0x00007f70a3ef41d4 in __libc_message (do_abort=1, fmt=fmt@entry=0x7f70a4002a10 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007f70a3f01d76 in malloc_printerr (ptr=0x134bc20, str=0x7f70a3ffeb84 "malloc(): memory corruption", action=<optimized out>) at malloc.c:4996
#4 _int_malloc (av=0x7f70a423f760 <main_arena>, bytes=300) at malloc.c:3447
#5 0x00007f70a3f035f0 in __GI___libc_malloc (bytes=300) at malloc.c:2891
#6 0x00007f70a3efdbef in __GI__IO_str_overflow (fp=0x7fff5a684910, c=116) at strops.c:119
#7 0x00007f70a3efc54c in __GI__IO_default_xsputn (f=0x7fff5a684910, data=<optimized out>, n=8) at genops.c:480
#8 0x00007f70a3eca79a in _IO_vfprintf_internal (s=s@entry=0x7fff5a684910, format=<optimized out>, format@entry=0x4193a2 "<entry name=\"%s\">%s</entry>", ap=ap@entry=0x7fff5a684a48) at vfprintf.c:1692
#9 0x00007f70a3f8b385 in __GI___vasprintf_chk (result_ptr=result_ptr@entry=0x7fff5a684a40, flags=flags@entry=1, format=format@entry=0x4193a2 "<entry name=\"%s\">%s</entry>", args=args@entry=0x7fff5a684a48)
    at vasprintf_chk.c:66
#10 0x00000000004041e0 in vasprintf (__ap=0x7fff5a684a48, __fmt=<optimized out>, __ptr=0x7fff5a684a40) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:210
#11 appendf (str=str@entry=0x624ab8 <doc>, fmt=fmt@entry=0x4193a2 "<entry name=\"%s\">%s</entry>") at procenv.c:2584
#12 0x00000000004078ab in entry (name=name@entry=0x41af24 "description", fmt=fmt@entry=0x4192b3 "'%s'") at procenv.c:1072
#13 0x0000000000417755 in show_signals () at procenv.c:1675
#14 0x0000000000418c0f in dump () at procenv.c:2956
#15 0x0000000000403587 in main (argc=2, argv=<optimized out>) at procenv.c:7143

Problem is that strerror(3) is returning utf-8 chars so procenv should convert all data to wchar_t.

Work around:

$ LANG=C make check

Related branches

James Hunt (jamesodhunt) on 2014-06-02
Changed in procenv:
importance: Undecided → High
assignee: nobody → James Hunt (jamesodhunt)
status: New → In Progress
James Hunt (jamesodhunt) on 2014-06-23
summary: - procenv cannot handle utf-8 chars when producing XML output
+ procenv cannot handle utf-8 chars when producing XML or JSON output
James Hunt (jamesodhunt) on 2014-08-16
Changed in procenv:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers