public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: rob.renfrew@epiphany.com
To: gcc-gnats@gcc.gnu.org
Subject: libstdc++/2932: new operator segfaults for arrays using pthreads on hpux
Date: Thu, 24 May 2001 16:56:00 -0000	[thread overview]
Message-ID: <20010524234836.31400.qmail@sourceware.cygnus.com> (raw)

>Number:         2932
>Category:       libstdc++
>Synopsis:       new operator segfaults for arrays using pthreads on hpux
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 24 16:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     rob.renfrew@epiphany.com
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
HP-UX 11
>Description:
spawning many threads which each allocate new arrays will cause a segmentation fault on HPUX11.  error does not occur using new to allocate non-arrays, or with malloc().
>How-To-Repeat:
build as:
gcc -o RTT RTT.cpp -lpthread
run ./RTT

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="RTT.cpp"
Content-Disposition: inline; filename="RTT.cpp"

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

#define NUM_THREADS	100
#define NUM_LOOPS 100
#define RT_SIZE 100

//typedef unsigned short Rtype;
typedef char Rtype;

void* memory_test(void *arg) {
	for (int i = 0; i < NUM_LOOPS; i++) {
		Rtype* rt = new Rtype[RT_SIZE];
		delete rt;
	}
}

int main(int argc, char **argv) {
	int status;
	pthread_t *threads;
	threads = new pthread_t[NUM_THREADS];
	for (int i = 0; i < NUM_THREADS; i++) {
		status = pthread_create(&(threads[i]), NULL, memory_test, NULL);
		if (status != 0) {
			fprintf(stderr, "failed: pthread_create: %d\n", i);
			exit(-1);
		}
	}
	void *trash;
	for (int i = 0; i < NUM_THREADS; i++) {
		status = pthread_join(threads[i], &trash);
		if (status != 0) {
			fprintf(stderr, "failed: pthread_join: %d\n", i);
			exit(-1);
		}
	}
	return 0;
}


             reply	other threads:[~2001-05-24 16:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-24 16:56 rob.renfrew [this message]
2001-06-13 10:04 bkoz
2001-06-26 17:15 bkoz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010524234836.31400.qmail@sourceware.cygnus.com \
    --to=rob.renfrew@epiphany.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).