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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:56:52+00:00 2026-05-25T02:56:52+00:00

These days i found a blog the mentioned abort function in C. The following

  • 0

These days i found a blog the mentioned abort function in C.

The following is the source code of abort function:
http://cristi.indefero.net/p/uClibc-cristi/source/tree/0_9_14/libc/stdlib/abort.c

I found that it use the hlt instruction (My PC is x86).

But seems that hlt must run in ring 0.
(refer to wiki http://en.wikipedia.org/wiki/HLT)

It seems that the abort is running in the user space. So the usage of the hlt instruction in abort seems illegal.

BTW, I try to run hlt in linux and windows. But i encounter an error.

In linux:

#include <iostream>
using namespace std;

#define HLT_INST asm("hlt")

int main(){
  cout<<"whill run halt"<<endl;

  HLT_INST; //result in SIGSEGV error
  return 0;
}

In Windows:

cout<<"will run hlg"<<endl;
/*Unhandled exception at 0x0040101d in test_learn.exe: 0xC0000096: Privileged instruction.
*/
__asm{
    hlt;
}
  • 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-25T02:56:53+00:00Added an answer on May 25, 2026 at 2:56 am

    The abort function only uses the hlt instruction after sending SIGABRT fails. If you read the source code, the function first tries to:

    raise(SIGABRT);
    

    And then calls the invalid instruction :

    /* Still here?  Try to suicide with an illegal instruction */
    if (been_there_done_that == 2) {
        been_there_done_that++;
        ABORT_INSTRUCTION;
    }
    

    So you are right, hlt requires ring 0 privileges. That’s precisely what makes it an invalid instruction. Executing it will call an invalid-instruction handler, which is in your case (I suppose) SIGSEGV.

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

Sidebar

Related Questions

These days I am reading some javascript source codes,however I found some syntax that
These days I'm working on a VB.NET application which can be used to edit,
I installed integrity app these days. and found some issues. I follow this. $
I hav been spending some time these days going through gcc internals. I found
I am dealing with memory leak in C code these days. I am amazed
Some days ago I looked at boost sources and found interesting typedef . There
These days, more languages are using unicode, which is a good thing. But it
These days web addresses can also include non-ASCII characters. So every modern browser and
Like most web developers these days, I'm thoroughly enjoying the benefits of solid MVC
Web-Applications these days make extensive use of Javascript, for example various Google Products like

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.