Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8222733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:22:42+00:00 2026-06-07T14:22:42+00:00

if the function called by pthread_create has the following structure try{ …code…. pthread_detach(pthread_self()); pthread_exit(NULL);

  • 0

if the function called by pthread_create has the following structure

try{
  ...code....
  pthread_detach(pthread_self());
  pthread_exit(NULL);
}catch(...){
  std::cout<<"I am here"<<std::endl;
}

why does the exception handler for ellipsis get called at the execution of pthread_exit?
(note that std::exception, for instance, are not thrown)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:22:44+00:00Added an answer on June 7, 2026 at 2:22 pm

    At least in GCC pthread_exit might throw an ___forced_unwind exception, that is used for unwinding the stack during the thread exit. It does not inherit from std::exception, and therefore cannot be caught as one. If you do catch that exception, be sure to re-throw it so it can do its job:

    try {
    ...
    } catch (abi::___forced_unwind&) {
        throw;
    } catch (...) {
        // whatever
    }
    

    The reason an exception is thrown is that pthread_exit is specified never to return. Having it throw guarantees cleanup of stack-allocated variables, and no execution of code after its location (unless you catch the unwind exception…). However this is not portable, and Clang for example uses a completely different mechanism.

    BTW, this is yet another case where the catch (...) idiom does more harm than good. It is sometimes used to “stabilize” code that is throwing unknown exceptions. But that only defers the visibility of the damage to a later time and place, making it impossible to identify the real origin of the problem. The only reasonable thing to do in such a catch is minimal cleanups, possibly logging, and then rethrowing. A process that crashes due to an unhandled exception is not a pretty sight, but it can provide a debugable crash dump that clearly shows the faulty command. But that’s just my grudge against catch (...), which is barely related to pthread_exit…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Django has a decorator function called @transaction.commit_manually . I am attempting to pass a
Possible Duplicate: Multiple arguments to function called by pthread_create()? How to pass more than
Can I call another function in a thread runner function, called by a pthread_create()
I have a function called call facebook. call_facebook(284328420994); call_facebook(197214710347172); It runs severaltimes It makes
I have a function called PreProcessSource, which allocates a boost::wave::context and does some preprocessing;
Heres my custom function called doIt which as im sure you can see simply
I have a function called Colorbox (jQuery plugin) that takes a number of parameters
I have this function called ProperCase that takes a string, then converts the first
I have a Java function called testForNull public static void testForNull(Object obj) { if
I know there is a function called ISDATE to validate DATETIME columns, but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.