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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:06:37+00:00 2026-05-26T23:06:37+00:00

From makecontext() manual… Due to limitations in the current pthread implementation, makecontext should not

  • 0

From makecontext() manual…

Due to limitations in the current pthread implementation, makecontext should not be used in programs which link against the pthread(3) library (whether threads are used or not).

Now my question is, why it doesn’t work and what are the alternative methods. Actually I’m interested in switching stacks in a user-level thread at some points, but I’m seeing that when I call swapcontext(), I get segmentation faults every now and then. What should I do?

I want to achieve something like this:

void thread_func(void * thread_args)
{
 a();
 b();
 getcontext/makecontext/swapcontext to call c();
 d();
 ....
}

So in this case, I want to use a separate stack when executing function c().

  • 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-05-26T23:06:38+00:00Added an answer on May 26, 2026 at 11:06 pm

    Due to limitations in the current pthread implementation, makecontext should not be used in programs which link against the pthread(3) library

    That section of the manual applies to LinuxThreads, which used to round %esp value up to find current thread descriptor. That (obviously) wouldn’t produce a valid thread descriptor if you were executing on an alternate stack.

    LinuxThreads are no longer used by any Linux distributed in the last 5+ years, and {get,make,swap}context work just fine with NPTL threads.

    EDIT: Actually, I only see the “due to limitations” in NetBSD docs, not in Linux docs.

    when I do swapcontext, I get segmentation faults every now and then

    You have a bug that shows up as a segmentation fault now and then. You haven’t supplied enough info to guess where that bug may be.

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

Sidebar

Related Questions

From JSP file accessed another JSP file which acts like java class, this used
From PEP 8 : - Imports should usually be on separate lines, e.g.: Yes:
I have used makecontext/swapcontext successfully for shifting the stack. However, when I try to
In unix environments the makecontext()/swapcontext() family of functions is sometimes used to implement coroutines
From Python docs: http://docs.python.org/library/stdtypes.html#comparisons Implementation note: Objects of different types except numbers are ordered
From what I've ready you should be able to use the 'value' property of
From what I've read, information placed into TempData will be there for the current
From a web developer point of view, what changes are expected in the development
From a desktop application developer point of view, is there any difference between developing
From what I've read, VS 2008 SP1 and Team Foundation Server SP1 packages are

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.