Skip to Content.
Sympa Menu

mathemagix-devel - Re: [Mathemagix] mmx_parser

Subject: Mathemagix

List archive

Re: [Mathemagix] mmx_parser


Chronological Thread 
  • From: Joris van der Hoeven <address@concealed>
  • To: address@concealed
  • Subject: Re: [Mathemagix] mmx_parser
  • Date: Wed, 7 Nov 2007 11:41:55 +0100

On Wed, Nov 07, 2007 at 10:12:35AM +0100, Grégoire Lecerf wrote:
> Hi,
> I've just modified mmx_parser.ypp to fix the stack overflow problem.
> Reallocation should now be done properly so that you can parse huge files
> involving long right reductions :-)
> The initial size of the parser stack is set to 8 during a "test period"
> -- it will then be increased to 128 or 256.
> During this perdiod the ERROR_VERBOSE is disabled due to a bug in bison
> until
> the lattest 2.3 version. Hopefully this bug is already fixed for the
> next version.
> I will take that into account within the installation process.
> Grégoire.

Using a routine as below instead of a huge macro is nicer for debugging...

bool
my_overflow (void* obj, char* message, short** sstackp, int sstack_byte_size,
YYSTYPE** vstackp, int vstack_byte_size, YYSIZE_T* stack_sizep)
{
do {
if (*(stack_sizep) >= YYMAXDEPTH) {
yyerror (message);
return true;
}
nat new_size = *(stack_sizep) * 2;
if (new_size > YYMAXDEPTH || new_size < *(stack_sizep))
new_size = YYMAXDEPTH;
short *old_sstack = current_sstack;
short *new_sstack = new short [new_size];
if (new_sstack == NULL) {
yyerror (message);
return true;
}
current_sstack = new_sstack;
memcpy (current_sstack, *(sstackp), (sstack_byte_size));
if (old_sstack != NULL)
delete old_sstack;
YYSTYPE *old_vstack = current_vstack;
YYSTYPE *new_vstack = new YYSTYPE [new_size];
if (new_vstack == NULL) {
yyerror (message);
return true;
}
current_vstack = new_vstack;
for (nat _i = 0; _i < *(stack_sizep); ++_i)
current_vstack[_i] = (*(vstackp))[_i];
if (old_vstack != NULL)
delete old_vstack;
*(sstackp) = current_sstack;
*(vstackp) = current_vstack;
*(stack_sizep) = new_size;
} while (0); // The final stacks are freed at the end of mmx_parse ()
return false;
}



Archive powered by MHonArc 2.6.18.

Top of Page