Re: Re: [perl #39777] Large Subroutine Segfaults IMCC
On Tue, Jul 11, 2006 at 12:24:47AM -0500, Vishal Soni wrote: Other thing I could do is re-allocate the Macro Array size when it gets full. So it would not fail until system starts swapping :-) I would prefer the second option. Because it might hinder your and other language development. This might become a bigger issue as you start writing bigger programs or libraries. Reallocation of the macro array is only one part of a fix. The bigger problem is that macros are kept in a global and never invalidated or freed. This means that, if file A defines some macros or constants, these macros are also in scope, when compiling a file B. A fix needs these steps: - manage the macro array within imc_info[1] - reallocate it on demand - clean the array after compiling a file It'd be also reasonable to use a hash to avoid linear search in existing macros/constants. [1] this is a bit tricky, as .include should of course keep the defines, while compiling a different file needs cleanup. leo
Re: Re: [perl #39777] Large Subroutine Segfaults IMCC
Vishal Soni [EMAIL PROTECTED] wrote: Hi Matt, This patch is because the number of .constant decls in IMCC is limited to 4096. This is a todo to make this dynamic. The evil code seems to have about 4200 .constant decls being generated. Here is the patch to fix it. For now I bumped up the limit to 8192 and it works. But this is a TODO for sure. Thanks for investigating this, Vishal. Coke mentioned on IRC that he had bumped this number up once before. I'll change the ticket in RT to document the real problem. In the meantime, would it be possible to die with an error saying too many .constants instead of just segfaulting? Thanks again, -- matt diephouse http://matt.diephouse.com
Re: Re: [perl #39777] Large Subroutine Segfaults IMCC
Hi Matt, I can patch up something that would spit out an error message and exit rather than Segfaulting. Right now there is no bounds check. Other thing I could do is re-allocate the Macro Array size when it gets full. So it would not fail until system starts swapping :-) I would prefer the second option. Because it might hinder your and other language development. This might become a bigger issue as you start writing bigger programs or libraries. Let me know your thoughts. -Vishal On Mon, 2006-07-10 at 22:11 -0700, Matt Diephouse wrote: Vishal Soni [EMAIL PROTECTED] wrote: Hi Matt, This patch is because the number of .constant decls in IMCC is limited to 4096. This is a todo to make this dynamic. The evil code seems to have about 4200 .constant decls being generated. Here is the patch to fix it. For now I bumped up the limit to 8192 and it works. But this is a TODO for sure. Thanks for investigating this, Vishal. Coke mentioned on IRC that he had bumped this number up once before. I'll change the ticket in RT to document the real problem. In the meantime, would it be possible to die with an error saying too many .constants instead of just segfaulting? Thanks again,
Re: [perl #39777] Large Subroutine Segfaults IMCC
Hi Matt, This patch is because the number of .constant decls in IMCC is limited to 4096. This is a todo to make this dynamic. The evil code seems to have about 4200 .constant decls being generated. Here is the patch to fix it. For now I bumped up the limit to 8192 and it works. But this is a TODO for sure. I ran the after bumnping up the limit and it seems to work. After applying the patch If you have lex perl Configure.pl --lex=lex If you have flex perl Configure.pl --lex=lex make -Vishal Index: compilers/imcc/imcc.l === --- compilers/imcc/imcc.l (revision 13220) +++ compilers/imcc/imcc.l (working copy) @@ -31,7 +31,7 @@ }; /* XXX: boe: rework this hack to use a hash */ -#define N_MACROS 4096 +#define N_MACROS 8192 struct macro_t macros[N_MACROS]; int num_macros = 0; On Sun, 2006-07-09 at 20:49 -0700, Matt Diephouse wrote: # New Ticket Created by Matt Diephouse # Please include the string: [perl #39777] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=39777 The attached file, which has a ~1 line subroutine, makes IMCC segfault. Segfault bad. -- Matt Diephouse