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 8749113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:38:26+00:00 2026-06-13T12:38:26+00:00

As stated in http://en.cppreference.com/w/cpp/error/terminate there are many reasons to call terminate. I can imagine

  • 0

As stated in http://en.cppreference.com/w/cpp/error/terminate there are many reasons to call terminate. I can imagine case where just almost in the same time some of these reasons happen in two threads.

Q1 Can the terminate function set by std::set_terminate be called twice or more at the same time, by the same time I mean second call begins before first has ended.

  Thread1   Thread2
    |          |
    _          |
    t          |
    e          |
    r          |
    m          |
    i          _
    n          t
    a          e
    t          r
    e          m
    -          ?

Q2 If Q1==YES, then what happens if first terminate ended. I guess if it ended with std::abort, then program ends, but what happens if user provided terminate does not abort program?

Q3 Is the terminate function set by std::set_terminate called in context of the thread which caused this terminate call?

  • 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-13T12:38:26+00:00Added an answer on June 13, 2026 at 12:38 pm

    Q1

    Yes, std::terminate can be called concurrently.

    Q2

    The standard says it is undefined behavior for a terminate_handler to not “terminate execution of the program without returning to the caller”. In implementations I’m familiar with, if the terminate_handler attempts to return, either normally, or exceptionally, abort() will be called.

    Q3

    The function set by std::terminate is a global, not a thread local. So one thread can impact another.

    In C++98/03, the terminate_handler used when terminate is called due to an uncaught exception is the one that was in effect when the exception was thrown, not the one in effect when terminate is actually called (though they are usually the same).

    In C++11 this was changed and the standard now says that the handler used is the one in place at the time terminate is called. This change was done by mistake and will most likely be corrected in a future draft. Here is the LWG issue tracking this issue:

    http://cplusplus.github.com/LWG/lwg-active.html#2111

    Update

    At the Spring 2015 meeting in Lenexa, KS, the LWG decided to standardize existing behavior and made it unspecified when a new terminate_handler goes into effect if set_terminate is called during stack unwinding. I.e. implementations are allowed to follow either the C++98/03 rules or the C++11 rules.

    To make your code portable, if you need to set a terminate_handler, do so during program startup, before any exceptions will be thrown, and do not make a habit of calling set_terminate after that.

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

Sidebar

Related Questions

As stated in http://www.boutell.com/newfaq/misc/urllength.html , HTTP query string have limited length. It can be
I just started using Twitter Bootstrap http://twitter.github.com/bootstrap/scaffolding.html and I'm looking for the grey/blue navbar
I´ve just started learning GWT and I´m trying to implement http://gwt.google.com/samples/Showcase/Showcase.html#!CwFileUpload and but failing
The documentation ( http://developer.android.com/guide/topics/manifest/manifest-element.html#uid ) only states I can't use raw strings and the
As stated in http://msdn.microsoft.com/en-us/library/dd377544(VS.85).aspx , ISampleGrabber accepts only videos with VIDEOINFOHEADER structure, but not
I was reading this document: http://www.fadden.com/techmisc/hdc/lesson11.htm In it he stated: Problem is, we don't
As stated here : http://codeigniter.com/user_guide/general/cli.html A page like : http://www.example.com/myController/myFunc/myParam can be run on
From HopStop's documentation: http://www.hopstop.com/developer/?action=documentation#6.1.3 for the GetRoute function, it is stated that instead of
According to: http://intendance.com/2011/03/31/enterprise-content-management-open-source-squiz-matrix/ They have stated: Most other open source content management systems options
I'm learning masm32, following some tutorials. In one tutorial: http://win32assembly.online.fr/tut3.html there is stated: LOCAL

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.