Branch: Tag:

2003-03-24

2003-03-24 12:23:32 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.301

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: interpret.c,v 1.300 2003/03/22 23:08:17 mast Exp $ + || $Id: interpret.c,v 1.301 2003/03/24 12:23:32 jonasw Exp $   */      #include "global.h" - RCSID("$Id: interpret.c,v 1.300 2003/03/22 23:08:17 mast Exp $"); + RCSID("$Id: interpret.c,v 1.301 2003/03/24 12:23:32 jonasw Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"
110:   }       - /* 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)
201:   #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;
223:    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;
2437: 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;
2449:       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;   }