From owner-freebsd-questions Wed Aug 29 5:53:37 2001 Delivered-To: freebsd-questions@freebsd.org Received: from flux.ptc.spbu.ru (flux.ptc.spbu.ru [195.19.225.195]) by hub.freebsd.org (Postfix) with ESMTP id E97D137B401 for ; Wed, 29 Aug 2001 05:53:31 -0700 (PDT) (envelope-from tchernov@pobox.spbu.ru) Received: from tchermob (tcher.dialup.spbu.ru [195.19.224.249]) by flux.ptc.spbu.ru (8.11.2/8.11.2/cf-1.1.rbl) with SMTP id f7TCt2f68345 for ; Wed, 29 Aug 2001 16:55:02 +0400 (MSD) Message-ID: <001901c13089$c0a24f80$0200a8c0@tchermob> From: "Igor Tchernov" To: Subject: operators new/delete with pthreads Date: Wed, 29 Aug 2001 16:54:02 +0400 MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Dear people, Although you don't like to answer questions like "why my programm doesn't work?", I've no way more to find why the error appears at the using new/delete operators with the pthreads. I've represented this error in small programm below. After few seconds running breaks this programm down with the "Segmentation fault" or "Bus error". This error appears in the FreeBSD but in the OpenBSD works this properly. What the reason? ----------------------------------- // test_new_delete.cpp : test new/delete operators in multithreading. // g++ -pthread test_new_delete.cpp #include #include class CTestNewDelete { public: char *pData; CTestNewDelete(); ~CTestNewDelete(); }; CTestNewDelete::CTestNewDelete() { pData = new char[10]; } CTestNewDelete::~CTestNewDelete() { delete [] pData; } static void ThreadFunc_1() { CTestNewDelete data; } static void ThreadFunc_2() { CTestNewDelete data; } static void* Thread_1(void *) { while(true) ThreadFunc_1(); return NULL; } static void* Thread_2(void *) { while(true) ThreadFunc_2(); return NULL; } int main(int argc, char* argv[]) { pthread_t thread1 = 0, thread2 = 0; if (pthread_create(&thread1, NULL, Thread_1, NULL) != 0) { printf("start Thread_1 failed"); exit(1); } if (pthread_create(&thread2, NULL, Thread_2, NULL) != 0) { printf("start Thread_2 failed"); exit(1); } while (true); return 0; } ----------------------------------- System: FreeBSD tcherdom 4.2-RELEASE FreeBSD 4.2-RELEASE #8: Sun Jan 21 17:05:56 MSK 200 1 root@tcherdom:/usr/src/sys/compile/TCHERDOM i386 Package: pth-1.3.7 GNU Portable Threads best regards, Igor Tchernov. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message