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

  • Home
  • SEARCH
  • 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 1014645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:16:51+00:00 2026-05-16T10:16:51+00:00

I am allocating memory in a C program using malloc . It’s possible for

  • 0

I am allocating memory in a C program using malloc. It’s possible for my program to allocate more memory than the system has room for, at which point the program crashes. For my purposes it would be better if malloc would just return NULL (like it’s apparently supposed to), so I can catch the error. Instead what it does is it throws an error saying “No memory available to program now: unsafe to call malloc.” And crashes the program.

How can I fix this?

Edit: I know that the program is crashing by itself and not because I’m trying to reference a null pointer. The program never directly calls malloc, but instead calls a function I wrote that calls malloc and then checks to see if it returns NULL. It’s never saying that malloc returned NULL.

Edit 2: If it’s helpful, here is the complete error output:

Program received signal: “EXC_BAD_ACCESS”.
sharedlibrary apply-load-rules all
warning: Unable to restore previously selected frame.
Data Formatters temporarily unavailable, will re-try after a ‘continue’. (The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use “set unwindonsignal on”
Evaluation of the expression containing the function (dlopen) will be abandoned.)
No memory available to program now: unsafe to call malloc

  • 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-16T10:16:52+00:00Added an answer on May 16, 2026 at 10:16 am

    Once you scribble on the heap via buffer overruns, wild pointers or other bugs, malloc’s behavior becomes undefined and it could return anything.

    Malloc is simply a user-space library; there isn’t any magic contained within it. If I scribble all over your application’s linked list of customer names, you’ll get weird behavior when you later access that list. Malloc behaves in the same way, but since the use of malloc is distributed through the code, cause and effect have global reach.

    All of the answers are dancing around the fact that pointer errors are the single most prevalent source of defects in C code. You are lucky you are getting a SIGBUS which is the evidence of defect that may be widely separated from where and when the fault occurs. Use valgrind to help you find where the real defect is.

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

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to tell the search how many results you… May 16, 2026 at 11:56 am
  • Editorial Team
    Editorial Team added an answer I used this method in a recent project of mine… May 16, 2026 at 11:56 am
  • Editorial Team
    Editorial Team added an answer The problem with using a cron job for something like… May 16, 2026 at 11:56 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

We allocate memory in C using malloc and in C++ using new. I know
I want to create a custom malloc which allocates memory blocks within a given
What's the advantage of using malloc (besides the NULL return on failure) over static
Obviously Wikipedia has a fair amount of information on the topic, but I wanted
A friend of mine was asked, during a job interview, to write a program
I have a small single-threaded C++ application, compiled and linked using Visual Studio 2005,
I am toying with certain caching algorithm, which is challenging somewhat. Basically, it needs
I would like to know what are the common memory management issues associated with
I recently benchmarked the .NET 4 garbage collector, allocating intensively from several threads. When
I am using Glassfish v3 server. Usually the DB connection with EJB3 + JPA

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.