Bug 73413 - [libkse] [patch] pthread (libkse) library is broken on sparc64
Summary: [libkse] [patch] pthread (libkse) library is broken on sparc64
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: sparc64 (show other bugs)
Version: 5.3-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Tom Rhodes
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-02 13:20 UTC by bel
Modified: 2008-06-10 02:04 UTC (History)
0 users

See Also:


Attachments
libkse.patch (5.68 KB, patch)
2004-11-02 13:20 UTC, bel
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bel 2004-11-02 13:20:19 UTC
	Programs compiled with libkse does not work at all.

Fix: I have preliminary patch. Also needed kernel patch from
PR sparc64/72998 <http://www.freebsd.org/cgi/query-pr.cgi?pr=sparc64/72998>

How-To-Repeat: 
	Use this test code:

--- ss2.c begins here ---
#include <stdio.h>
#include <string.h>
#include <pthread.h>

static void *
entry1(void *argp)
{
	long x = 0, y = 1;
	while (1) {
		if ((y - x) != 1) {
			fprintf(stderr, "FATAL ERROR: (y - x) != 1, "
				"x = %ld, y = %ld\n", x, y);
		}
		x++; y++;
	}
	return NULL;
}

void *
entry2(void *argp)
{
	long x = 0, y = -1;
	while (1) {
		if ((y - x) != -1) {
			fprintf(stderr, "FATAL ERROR: (y - x) != -1, "
				"x = %ld, y = %ld\n", x, y);
		}
		x--; y--;
	}
	return NULL;
}

static void *
entry3(void *argp)
{
	long x = 0, y = 2;
	while (1) {
		if ((y - x) != 2) {
			fprintf(stderr, "FATAL ERROR: (y - x) != 2, "
				"x = %ld, y = %ld\n", x, y);
		}
		x += 2; y += 2;
	}
	return NULL;
}

static void *
entry4(void *argp)
{
	long x = 0, y = -2;
	while (1) {
		if ((y - x) != -2) {
			fprintf(stderr, "FATAL ERROR: (y - x) != -2, "
				"x = %ld, y = %ld\n", x, y);
		}
		x -= 2; y -= 2;
	}
	return NULL;
}

struct thr_table {
	void * 		(*entry)(void *);
	pthread_t	thread;
};

static struct thr_table threads[] = {
	{entry1, NULL},
	{entry2, NULL},
	{entry3, NULL},
	{entry4, NULL},
	{NULL, NULL}
};

int
main()
{
	int error;
	struct thr_table *pthr;

	for (pthr = threads; pthr->entry != NULL; pthr++) {
		error = pthread_create(&pthr->thread, NULL, pthr->entry, NULL);
		if (error)
			fprintf(stderr, "Error in pthread_create(): %s\n",
				strerror(error));
	}

	sleep(20);

	return 0;
}
--- ss2.c ends here ---

bel@bel$ cc -g -o ss2 ss2.c -lkse
bel@bel$ ./ss2
Segmentation fault (core dumped)

bel@bel$ gdb ss2 ss2.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
[...]
This GDB was configured as "sparc64-marcel-freebsd"...
Core was generated by `ss2'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libkse.so.1...done.
Loaded symbols for /usr/lib/libkse.so.1
Reading symbols from /lib/libc.so.5...done.
Loaded symbols for /lib/libc.so.5
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x0000000040507bb0 in __utrap_panic () from /lib/libc.so.5
(gdb) bt
#0  0x0000000040507bb0 in __utrap_panic () from /lib/libc.so.5
#1  0x00000000405079d4 in __sparc_utrap () from /lib/libc.so.5
#2  0x000000004049ab6c in __sparc_utrap_gen () from /lib/libc.so.5
#3  0x000000004049ab6c in __sparc_utrap_gen () from /lib/libc.so.5
Previous frame identical to this frame (corrupt stack?)
(gdb) quit
Comment 1 Tom Rhodes freebsd_committer freebsd_triage 2005-09-07 15:46:52 UTC
Responsible Changed
From-To: freebsd-sparc64->trhodes

I'd like to take a look at this.
Comment 2 Pietro Cerutti freebsd_committer freebsd_triage 2008-06-10 02:04:53 UTC
State Changed
From-To: open->closed

KSE is no more...