comp.programming.threads 뉴스그룹에서 허락 없이 가져옴.

맘대로 갖다 붙이다가 문제 생겨도 책임안짐.
원문은 http://groups.google.com/group/comp.programming.threads/browse_thread/thread/652bcf186fbbf697/f63757846514e5e5
아 길다.

D'artagnan

I'm using Pthreads in a C++ program that uses exceptions. When one
thread is cancelled (cancellation state is deferred) by the main
thread, it throws some mysterious exception which cannot even be caught
by "catch(...)". The program aborts with the following error message:

FATAL: exception not rethrown
Abort

Anybody have ideas how to avoid this problem? Specifically, how to
catch the cancellation exception, or how to ignore it? Thanks a lot.

- C++의 예외 기능을 사용하는 프로그램에서 pthread 기능을 쓰고 있다. 쓰레드 하나가주 쓰레드에 의해  중단될 때(중단 상태는 deferred) "catch(...)" 구절로도 잡아낼 수 없는 괴상한 예외를 하나 던져주고, 아래와 같은 메시지를 보여주면서 끝나 버린다.
FATAL: exception not rethrown
Abort

누구 이 문제에 대해 아는 사람? 특히 중단 시점의 예외를 받아내거나 무시하는 방법에 대해 아는 사람 있수? 있으면 감사. 없어도 감사.



David Butenhof

D'artagnan wrote:
(생략)

POSIX is a C language standard, and POSIX threads are part of POSIX. For portable correctness, you need 'extern "C"' linkage for thread start routines, cancellation cleanup handlers, UNIX signal handlers, and any other functions in your application called by POSIX. (Anywhere you pass the address of a function.)
POSIX and C don't know about exceptions.

POSIX는 C 언어 표준이고, POSIX 쓰레드는 POSIX의 일부다. 간단한 해결책으로는 쓰레드 시작 루틴/중단 및 정리 처리함수/신호 처리기/기타등등 POSIX와 관계있는 부분을 'extern "C"' 구절로 둘러싸 주는 것이다. (함수의 주소값을 넘겨주는 부분 말하는 거다)
POSIX와 C는 예외에 대해 모른다.

(또 생략)

그러나 본인의 머리를 폭발시키던 이 골치아픈 문제는 엉뚱한 데서 해결이 되고야 말았으니.

pthread_exit를 안쓰니 문제가 싸그리 사라지더라. ㅡ_ㅡ

크리에이티브 커먼즈 라이센스
Creative Commons License
2008/05/07 15:52 2008/05/07 15:52
Posted by 호빵
TAG ,

트랙백 주소
http://hoppang.net/tc/trackback/12

댓글을 달아 주세요

  1. 비밀방문자 2008/07/27 04:36 PERMALINK M/D REPLY

    관리자만 볼 수 있는 댓글입니다.

[로그인][오픈아이디란?]