Subject: lib/24023: pthread assertion failure
To: None <gnats-bugs@gnats.NetBSD.org>
From: Min Sik Kim <minskim@bawi.org>
List: netbsd-bugs
Date: 01/08/2004 10:52:30
>Number:         24023
>Category:       lib
>Synopsis:       pthread assertion failure
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 08 16:53:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Min Sik Kim
>Release:        NetBSD 1.6ZG
>Organization:
>Environment:
System: NetBSD sulley.infnis.com 1.6ZG NetBSD 1.6ZG (SULLEY) #1: Tue Dec 16 01:53:13 CST 2003 root@sulley.infnis.com:/usr/obj/sys/arch/i386/compile/SULLEY i386
Architecture: i386
Machine: i386
>Description:
An assertion failed in pthread while I was packaging
gnome-terminal-2.4.2.  gnome-terminal tests all possible charsets
using iconv to figure out which ones are available.  After trying
about 30 charsets, iconv_close() dumps core due to assertion failure
in pthread codes.

A *streamlined* version of gnome-terminal is attached below.  It
iterates over 32 charsets, calling iconv_open() and iconv_close() for
each.

Output::

BEGIN===================================================================
... (OK for 27 charsets)

DEBUG: testing charset GB18030.
DEBUG: Available
assertion "next != 0" failed: file "/usr/src/lib/libpthread/pthread_run.c", line 123, function "pthread__next"
Abort (core dumped)
END=====================================================================

I compiled this with the following command.

  cc -pthread -o terminal terminal.c

Without '-pthread', it runs well.  The assertion failure happens only
when '-pthread' is given.  I'm running one-month old -current (1.6ZG)
on i386.

>How-To-Repeat:
Compile the following program with '-pthread' option and run it.

terminal.c =============================================================
#include <stdio.h>
#include <iconv.h>

const int N_CHARSETS = 32;

static char *charsets[] = {
    "ISO-8859-1",
    "ISO-8859-2",
    "ISO-8859-3",
    "ISO-8859-4",
    "ISO-8859-5",
    "ISO-8859-6",
    "ISO-8859-7",
    "ISO-8859-8",
    "ISO-8859-8-I",
    "ISO-8859-9",
    "ISO-8859-10",
    "ISO-8859-13",
    "ISO-8859-14",
    "ISO-8859-15",
    "ISO-8859-16",
    "UTF-7",
    "UTF-8",
    "UTF-16",
    "UCS-2",
    "UCS-4",
    "ARMSCII-8",
    "BIG5",
    "BIG5-HKSCS",
    "CP866",
    "EUC-JP",
    "EUC-KR",
    "EUC-TW",
    "GB18030",
    "GB2312",
    "GBK",
    "GEORGIAN-ACADEMY",
    "HZ",
};

int main()
{
  int i;
  iconv_t cd;

  for (i = 0; i < N_CHARSETS; i++) {
    cd = iconv_open (charsets[i], charsets[i]);
    fprintf(stderr, "DEBUG: testing charset %s.\n", charsets[i]);
    if (cd != (iconv_t)-1) {
      fprintf(stderr, "DEBUG: Available\n");
      iconv_close(cd);
    } else {
      fprintf(stderr, "DEBUG: Not available.\n");
    }
    fprintf(stderr, "DEBUG: Done.\n\n");
  }
  return 0;
}


>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: