From mboxrd@z Thu Jan 1 00:00:00 1970 From: "aurelien.cornet" To: gcc@gcc.gnu.org Subject: Are exception with gcc 2.95.2 thread-safe? Date: Tue, 21 Mar 2000 03:47:00 -0000 Message-id: <38D7612C.9FD0EADF@tms.thomson-csf.com> X-SW-Source: 2000-03/msg00525.html Content-type: multipart/mixed; boundary="----------=_1583532956-673-17" This is a multi-part message in MIME format... ------------=_1583532956-673-17 Content-length: 773 The usual answer to this question is: The ANSI/ISO C++ Professional Programmer's Handbook (Danny Kalev) "In a multi-threading environment, exception handling should be thread-safe, but a single threading environment can implement exception handling in an non-thread-safe manner; this is implementation-dependent issue." I try the attached progam on Linux, Sun, Aix: In a main procedure, a try block creates a thread, sleep 2s (let the thread to be run), then throw an exception. We expected that this exception will be catched in main and the program terminates. But this program will never terminate and the result is: Thread has started Exception catched in thread Is it a bug? Can we use exception in a multi-threading program? Best regards. Aurelien. main.C ------------=_1583532956-673-17 Content-Type: text/x-c; charset=us-ascii; name="main.C" Content-Disposition: inline; filename="main.C" Content-Transfer-Encoding: base64 Content-Length: 671 I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8dW5pc3RkLmg+DQojaW5j bHVkZSA8cHRocmVhZC5oPg0KDQojaW5jbHVkZSA8aW9zdHJlYW0uaD4NCg0K dm9pZCAqIHRocmVhZF9mICh2b2lkICopIHsNCiAgdHJ5IHsNCiAgICBjb3V0 IDw8ICJUaHJlYWQgaGFzIHN0YXJ0ZWQgIiA8PCBlbmRsOw0KICAgIGZvciAo OzspIHNsZWVwICgxMDAwMCk7DQoNCiAgfSBjYXRjaCAoaW50IGkpIHsNCiAg ICBjb3V0IDw8ICJFeGNlcHRpb24gY2F0Y2hlZCBpbiB0aHJlYWQiIDw8IGVu ZGw7DQogIH0NCn0NCg0KaW50IG1haW4gKCkgew0KICB0cnkgew0KICAgIHB0 aHJlYWRfdCB0aHJlYWQ7DQogICAgcHRocmVhZF9jcmVhdGUgKCZ0aHJlYWQs IDAsIHRocmVhZF9mLCAwKTsNCg0KICAgIHNsZWVwICgyKTsNCiAgICB0aHJv dyAxMDsNCg0KICB9IGNhdGNoIChpbnQgaSkgew0KICAgIGNvdXQgPDwgImV4 Y2VwdGlvbiBjYXRjaGVkIGluIG1haW4iIDw8IGVuZGw7DQogIH0NCn0NCg== ------------=_1583532956-673-17--