Subject: pthread assertion failure
To: None <current-users@NetBSD.org>
From: Min Sik Kim <minskim@bawi.org>
List: current-users
Date: 01/07/2004 23:42:32
Hi,

I encountered an assertion failure 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 at the end of this
message.  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.

Any advice?

-- 
 Min Sik Kim


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;
}