Hi,
I am trying to run a simple program (np=2) using LAM 7.1.1
on Linux. The parent program spawns(forks) a new process
and then performs a few malloc/putenvs. However, this
forked-process dies inexplicably in one of the calls to malloc.
I am using simple LAM setup and have tried on various linux
machines including SLES8(AMD64), RH72(IA32).
I have tried to run with LAM configured with memory manager off
(i.e. --with-memory-manager=none) and this seems to fix the problem.
However, I do want the memory-manager to be activated.
Please find simple C-program attached.
Any help much appreciated.
--
----------------------------------------
Phil Mason
Software Development Engineer
Ricardo Consulting Engineers Ltd
Email - Philip.Mason_at_[hidden]
Tel: 01273 794914
--
This e-mail and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this e-mail in error please notify the sender immediately
and delete this e-mail from your system. Please note that any views or opinions
presented in this e-mail are solely those of the author and do not necessarily
represent those of Ricardo (save for reports and other documentation formally
approved and signed for release to the intended recipient). Only Directors
or Duly Authorised Officers are authorised to enter into legally binding
obligations on behalf of Ricardo unless the obligation is contained within
a Ricardo Purchase Order.
Ricardo may monitor outgoing and incoming e-mails and other telecommunications
on its e-mail and telecommunications systems. By replying to this e-mail you
give consent to such monitoring. The recipient should check this e-mail and
any attachments for the presence of viruses. Ricardo accepts no liability for
any damage caused by any virus transmitted by this e-mail. "Ricardo" means
Ricardo plc and its subsidiary companies.
Ricardo plc is a public limited company registered in England with registered
number 00222915.
The registered office of Ricardo plc is Bridge Works, Shoreham-by Sea,
West Sussex, BN43 5FG.
#include <stdlib.h>
#include <unistd.h>
#include <mpi.h>
void spawn( void );
void jobber( void );
main(int argc, char **argv)
{
int me;
MPI_Init(&argc,&argv); /* Initialize MPI */
MPI_Comm_rank(MPI_COMM_WORLD,&me); /* Get rank */
if ( me == 0 ) spawn(); /* Spawn command, if master */
MPI_Finalize(); /* End it */
}
void spawn( void )
{
int pid;
pid = fork();
if (pid == -1) exit(1);
if (pid == 0) { /* Forked child */
jobber(); /* Do some stuff */
/* Would perform execvp here */
exit(0);
} else { /* Parent process, sleep a while */
sleep(5);
}
}
void jobber( void )
{
/* JOB 1 */
printf("Malloc'ing...\n");
malloc( 1000 );
printf("Malloc'ed\n");
putenv("VAR1=VALUE");
/* JOB 2 */
printf("Malloc'ing...\n");
malloc( 1000 );
printf("Malloc'ed\n");
putenv("VAR2=VALUE");
/* JOB 3 */
printf("Malloc'ing...\n");
malloc( 1000 );
printf("Malloc'ed\n");
putenv("VAR3=VALUE");
printf("Job done.\n");
}
|