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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:42:30+00:00 2026-06-04T00:42:30+00:00

I have a strange problem freeing allocated memory in my mpi program: Here is

  • 0

I have a strange problem freeing allocated memory in my mpi program:

Here is a code sample that produces the error for me:

void *out, *in;
int cnt = 2501; //if cnt<=2500: works perfectly. cnt>2500: crashes at free!

if((out = malloc(cnt * sizeof(double))) == NULL) 
    MPI_Abort(MPI_COMM_WORLD, MPI_ERR_OP);
if((in = malloc(cnt * sizeof(double))) == NULL) 
    MPI_Abort(MPI_COMM_WORLD, MPI_ERR_OP);

//Test data generation
//usage of MPI_Send and MPI_Reduce_local
//doing a lot of memcpy, assigning pointer synonyms to in and out, changing data to in and out

free(in);    //crashes here with "munmap_chunk(): invalid pointer" 
free(out);   //and here (if above line is commented out) with "double free or corruption (!prev)"

I ran it using valgrind:

 mpirun -np 2 valgrind  --leak-check=full --show-reachable=yes  ./foo

and got the following:

==6248== Warning: ignored attempt to set SIGRT32 handler in sigaction();
==6248==          the SIGRT32 signal is used internally by Valgrind
cr_libinit.c:183 cri_init: sigaction() failed: Invalid argument

==6248== HEAP SUMMARY:
==6248==     in use at exit: 0 bytes in 0 blocks
==6248==   total heap usage: 1 allocs, 1 frees, 25 bytes allocated
==6248== 
==6248== All heap blocks were freed -- no leaks are possible
==6248== 
=====================================================================================
=   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
=   EXIT CODE: 134

Any ideas about how to track this error down? Note that it only appears if cnt>2500!

  • 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-04T00:42:32+00:00Added an answer on June 4, 2026 at 12:42 am

    If you’re using GNU glibc, you can set the environment variable MALLOC_CHECK_ to 2 before running your program, to enable extra checking on memory-allocation calls—details here.

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

Sidebar

Related Questions

I have a strange problem with mod_rewrite, the rules that are relevant here are:
I have a strange problem that is only happening in a single location. I
I have a strange problem when using Entity Framework code first. When I return
I have a strange problem: I have a CSV file that I read correctly
I have a strange problem here, I want to create an emtpy trigger: SET
I have strange problem with run .exe program in my WebApplication. It works fine
Have a strange problem in that I have a Rake task that seems to
I have strange problem. I set a JProgressBar: private JProgressBar progressBar; public void foo()
I have a strange problem regarding null pointer exception. I'm posting the problematic code
I have a strange problem in my project. I have a class that inherits

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.