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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:11:57+00:00 2026-05-29T12:11:57+00:00

Information about the application: Linux – 2.4.1 Kernel m68k based embedded application Single process

  • 0

Information about the application:

  • Linux – 2.4.1 Kernel
  • m68k based embedded application
  • Single process multithreaded application

We have an application where we have implemented the connection for the SIGSEGV with a segmentation_handler function. In this segmentation handler we create a file, do a file write (like “obtained stack frame”), then using backtrace and symbols write all the stack trace into the same file.

Problem: We get a SIGSEGV (confirmed due to creation of the log file) but unfortunately the file is empty (0kb file) with no information in it. (Even the first string which is a plain string is not available in the file).

I want to understand in what scenarios such a thing can happen because we can solve the crash if we get the stack trace, but we don’t have it and the mechanism to get it did not work either 🙁

void segmentation_handler(int signal_no) { 
    char buffer[512]; ............. 
    InitLog();//Create a log file 
    printf("\n*** segmentation fault occured ***\n");
    fflush(stdout); 
    memset(buffer, 0, 512); 
    size = backtrace (array, 50); 
    strings = backtrace_symbols (array, size); 
    sprintf(buffer, "Obtained %d stack frames.\n", size); 
    Log(buffer);// Write the buffer into the file 
    for (n = 0; n < size; n++) { 
        sprintf(buffer, "%s\n", strings[n]); Log(buffer); 
    } 
    CloseLog();
}
  • 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-29T12:12:00+00:00Added an answer on May 29, 2026 at 12:12 pm

    Your segmentation handler is very naive and contains multiple errors. Here is a short list:

    1. You are calling fprintf() and multiple other functions which are not async signal safe. Consider, fprintf uses a lock internally to synch multiple calls to the same file descriptor from multiple threads. What if your segmentation fault was in the middle of printf and the lock was taken? you would dead lock in the middle of the segmentation handlers…

    2. You are allocating memory (call to backtrace_symbols), but if the segmentation fault was due to malloc arena corruption (a very likely cause of segmentation violations) you would double fault inside the segmentation handler.

    3. If multiple threads cause an exception in the same time the code will open multiple times the file and run over the log.

    There are other problems, but these are the basics…

    There is a video on my lecture on how to write proper fault handlers available here: http://free-electrons.com/pub/video/2008/ols/ols2008-gilad-ben-yossef-fault-handlers.ogg

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

Sidebar

Related Questions

I have a combobox in a view that receives information about application state changes,
I have a java desktop application with information about several entities. There is a
I have a Rails application that lists information about local services. My objectives for
I have an AlertDialog with a short information about my application and I would
I need to detect information about the Application Server my EJBs are running in.
Does anyone have any information about getting the current versions of ASP.NET MVC (Preview
I have an application written in Java to run on Linux. I'm developing in
I'm currently developing an application which needs a lot of system and process information,
I'm trying to present some information in a Swing application about the existance of
I build an application on a machine running Linux (Debian) with kernel 2.6.26-2-amd64 and

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.