Branch: Tag:

2003-03-23

2003-03-23 12:35:29 by Jonas Wallden <jonasw@roxen.com>

Fix for clobbering of flag which needs to be kept separate for each
Pike_interpreter instance. This caused the Mac OS X version to call
munmap() for a block allocated using xalloc() which is a bad thing.

Rev: src/interpret.c:1.190

5:   \*/   /**/   #include "global.h" - RCSID("$Id: interpret.c,v 1.189 2003/01/30 13:43:56 grubba Exp $"); + RCSID("$Id: interpret.c,v 1.190 2003/03/23 12:35:29 jonasw Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"
85:   PMOD_EXPORT int Pike_stack_size = EVALUATOR_STACK_SIZE;       - /* mark stack, used to store markers into the normal stack */ - int mark_stack_malloced = 0; -  +    void push_sp_mark(void)   {    if(Pike_mark_sp == Pike_interpreter.mark_stack + Pike_stack_size)
164:   #define MMALLOC(X,Y) (Y *)mmap(0,X*sizeof(Y),PROT_READ|PROT_WRITE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANONYMOUS, fd, 0)       Pike_interpreter.evaluator_stack_malloced=0; -  mark_stack_malloced=0; +  Pike_interpreter.mark_stack_malloced=0;    Pike_interpreter.evaluator_stack=MMALLOC(Pike_stack_size,struct svalue);    Pike_interpreter.mark_stack=MMALLOC(Pike_stack_size, struct svalue *);    if((char *)MAP_FAILED == (char *)Pike_interpreter.evaluator_stack) Pike_interpreter.evaluator_stack=0;
184:    if(!Pike_interpreter.mark_stack)    {    Pike_interpreter.mark_stack=(struct svalue **)xalloc(Pike_stack_size*sizeof(struct svalue *)); -  mark_stack_malloced=1; +  Pike_interpreter.mark_stack_malloced=1;    }       Pike_sp=Pike_interpreter.evaluator_stack;
1748: Inside #if defined(USE_MMAP_FOR_STACK)
   munmap((char *)Pike_interpreter.evaluator_stack, Pike_stack_size*sizeof(struct svalue));    Pike_interpreter.evaluator_stack=0;    } -  if(!mark_stack_malloced) +  if(!Pike_interpreter.mark_stack_malloced)    {    munmap((char *)Pike_interpreter.mark_stack, Pike_stack_size*sizeof(struct svalue *));    Pike_interpreter.mark_stack=0;
1760:       Pike_interpreter.mark_stack=0;    Pike_interpreter.evaluator_stack=0; -  mark_stack_malloced=0; +  Pike_interpreter.mark_stack_malloced=0;    Pike_interpreter.evaluator_stack_malloced=0;   }