NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/45588: Switching many pthreads causes segv

>Number:         45588
>Category:       kern
>Synopsis:       Switching many pthreads causes segv
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 07 18:45:00 +0000 2011
>Originator:     Yui NARUSE
>Release:        NetBSD 5.99.56 x86_64
NetBSD 5.99.56 NetBSD 5.99.56 (GENERIC) #0: Sun Nov  6 
06:47:01 JST 2011 

Making many (1000) pthreads and switching them, it causes segv.
Run following program and it will segv.

% cat th.c
#include <pthread.h>
#include <sched.h>
#include <stdlib.h>
#define THREAD_COUNT 10000
void *dummy(void *p) {
    return NULL;
int main(void) {
    int i;
    pthread_t *threads = malloc(sizeof(pthread_t) * THREAD_COUNT);
    for (i = 0; i < THREAD_COUNT; i++) {
        if (pthread_create(&threads[i], NULL, dummy, &i)) {
    return 0;
% gcc -pthread th.c&&./a.out
a.out: _lwp_ctl: zsh: segmentation fault (core dumped)  ./a.out


Home | Main Index | Thread Index | Old Index