On Saturday 16 February 2008 15:26:41 Will Coleda wrote:

> On Feb 16, 2008 2:28 PM, chromatic <[EMAIL PROTECTED]> wrote:

> > Can either of you post a backtrace for the segfault?

> See attached.

Does this patch fix it?

-- c

=== compilers/imcc/imcc.l
==================================================================
--- compilers/imcc/imcc.l	(revision 25794)
+++ compilers/imcc/imcc.l	(local)
@@ -520,7 +520,7 @@
     }
 
 <emit,INITIAL>{DOT}{LETTER}{LETTERDIGIT}* {
-        char *macro_name = yytext + 1;
+        char *macro_name = str_dup(yytext + 1);
         const int type   = pmc_type(interp,
             string_from_cstring(interp, macro_name, 0));
 
@@ -531,13 +531,17 @@
 
             /* XXX: free valp->s if already used? Sounds like a good idea, but big segfaults if you do. */
             valp->s = buf;
+            mem_sys_free(macro_name);
             return INTC;
         }
 
         if (!expand_macro(valp, interp, macro_name, yyscanner)) {
+            mem_sys_free(macro_name);
             yyless(1);
             return DOT;
         }
+
+        mem_sys_free(macro_name);
     }
 
 <emit,INITIAL>{ID} {
=== compilers/imcc/imclexer.c
==================================================================
--- compilers/imcc/imclexer.c	(revision 25794)
+++ compilers/imcc/imclexer.c	(local)
@@ -30,7 +30,7 @@
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 34
+#define YY_FLEX_SUBMINOR_VERSION 33
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
@@ -52,7 +52,7 @@
 
 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
 
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#if __STDC_VERSION__ >= 199901L
 
 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
  * if you want the limit (max/min) macros for int types. 
@@ -115,12 +115,11 @@
 
 #else	/* ! __cplusplus */
 
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
+#if __STDC__
 
 #define YY_USE_CONST
 
-#endif	/* defined (__STDC__) */
+#endif	/* __STDC__ */
 #endif	/* ! __cplusplus */
 
 #ifdef YY_USE_CONST
@@ -156,6 +155,8 @@
 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
 #define yy_flex_debug yyg->yy_flex_debug_r
 
+int yylex_init (yyscan_t* scanner);
+
 /* Enter a start condition.  This macro really ought to take a parameter,
  * but we do it the disgusting crufty way forced on us by the ()-less
  * definition of BEGIN.
@@ -2772,7 +2773,7 @@
 
 
 
-#line 2776 "compilers/imcc/imclexer.c"
+#line 2777 "compilers/imcc/imclexer.c"
 
 #define INITIAL 0
 #define emit 1
@@ -2834,10 +2835,6 @@
 
 static int yy_init_globals (yyscan_t yyscanner );
 
-int yylex_init (yyscan_t* scanner);
-
-int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
-
 /* Accessor methods to globals.
    These are made visible to non-reentrant scanners for convenience. */
 
@@ -2915,7 +2912,7 @@
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO fwrite( yytext, yyleng, 1, yyout )
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -2926,7 +2923,7 @@
 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 		{ \
 		int c = '*'; \
-		int n; \
+		size_t n; \
 		for ( n = 0; n < max_size && \
 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
@@ -3031,7 +3028,7 @@
             return 0;
         }
 
-#line 3035 "compilers/imcc/imclexer.c"
+#line 3032 "compilers/imcc/imclexer.c"
 
 	if ( !yyg->yy_init )
 		{
@@ -3891,7 +3888,7 @@
 YY_RULE_SETUP
 #line 522 "compilers/imcc/imcc.l"
 {
-        char *macro_name = yytext + 1;
+        char *macro_name = str_dup(yytext + 1);
         const int type   = pmc_type(interp,
             string_from_cstring(interp, macro_name, 0));
 
@@ -3902,18 +3899,22 @@
 
             /* XXX: free valp->s if already used? Sounds like a good idea, but big segfaults if you do. */
             valp->s = buf;
+            mem_sys_free(macro_name);
             return INTC;
         }
 
         if (!expand_macro(valp, interp, macro_name, yyscanner)) {
+            mem_sys_free(macro_name);
             yyless(1);
             return DOT;
         }
+
+        mem_sys_free(macro_name);
     }
 	YY_BREAK
 case 118:
 YY_RULE_SETUP
-#line 543 "compilers/imcc/imcc.l"
+#line 547 "compilers/imcc/imcc.l"
 {
         if (!is_def) {
             SymReg *r = find_sym(interp, yytext);
@@ -3943,32 +3944,32 @@
 	YY_BREAK
 case 119:
 YY_RULE_SETUP
-#line 570 "compilers/imcc/imcc.l"
+#line 574 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, FLOATC);
 	YY_BREAK
 case 120:
 YY_RULE_SETUP
-#line 571 "compilers/imcc/imcc.l"
+#line 575 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, INTC);
 	YY_BREAK
 case 121:
 YY_RULE_SETUP
-#line 572 "compilers/imcc/imcc.l"
+#line 576 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, INTC);
 	YY_BREAK
 case 122:
 YY_RULE_SETUP
-#line 573 "compilers/imcc/imcc.l"
+#line 577 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, INTC);
 	YY_BREAK
 case 123:
 YY_RULE_SETUP
-#line 574 "compilers/imcc/imcc.l"
+#line 578 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, INTC);
 	YY_BREAK
 case 124:
 YY_RULE_SETUP
-#line 576 "compilers/imcc/imcc.l"
+#line 580 "compilers/imcc/imcc.l"
 {
         valp->s = str_dup(yytext);
 
@@ -3981,7 +3982,7 @@
 	YY_BREAK
 case 125:
 YY_RULE_SETUP
-#line 586 "compilers/imcc/imcc.l"
+#line 590 "compilers/imcc/imcc.l"
 {
         valp->s = str_dup(yytext);
 
@@ -3991,7 +3992,7 @@
 	YY_BREAK
 case 126:
 YY_RULE_SETUP
-#line 593 "compilers/imcc/imcc.l"
+#line 597 "compilers/imcc/imcc.l"
 {
         macro_frame_t *frame;
 
@@ -4023,7 +4024,7 @@
 	YY_BREAK
 case 127:
 YY_RULE_SETUP
-#line 622 "compilers/imcc/imcc.l"
+#line 626 "compilers/imcc/imcc.l"
 {
         /* charset:"..." */
         valp->s = str_dup(yytext);
@@ -4034,7 +4035,7 @@
 	YY_BREAK
 case 128:
 YY_RULE_SETUP
-#line 630 "compilers/imcc/imcc.l"
+#line 634 "compilers/imcc/imcc.l"
 {
         if (valp) (valp)->s = yytext;
         return IREG;
@@ -4042,7 +4043,7 @@
 	YY_BREAK
 case 129:
 YY_RULE_SETUP
-#line 635 "compilers/imcc/imcc.l"
+#line 639 "compilers/imcc/imcc.l"
 {
         if (valp) (valp)->s = yytext;
         return NREG;
@@ -4050,7 +4051,7 @@
 	YY_BREAK
 case 130:
 YY_RULE_SETUP
-#line 640 "compilers/imcc/imcc.l"
+#line 644 "compilers/imcc/imcc.l"
 {
         if (valp) (valp)->s = yytext;
         return SREG;
@@ -4058,7 +4059,7 @@
 	YY_BREAK
 case 131:
 YY_RULE_SETUP
-#line 645 "compilers/imcc/imcc.l"
+#line 649 "compilers/imcc/imcc.l"
 {
         if (valp) (valp)->s = yytext;
         return PREG;
@@ -4066,7 +4067,7 @@
 	YY_BREAK
 case 132:
 YY_RULE_SETUP
-#line 650 "compilers/imcc/imcc.l"
+#line 654 "compilers/imcc/imcc.l"
 {
         IMCC_fataly(interp, E_SyntaxError,
             "'%s' is not a valid register name", yytext);
@@ -4074,19 +4075,19 @@
 	YY_BREAK
 case 133:
 YY_RULE_SETUP
-#line 656 "compilers/imcc/imcc.l"
+#line 660 "compilers/imcc/imcc.l"
 /* skip */;
 	YY_BREAK
 case 134:
 YY_RULE_SETUP
-#line 658 "compilers/imcc/imcc.l"
+#line 662 "compilers/imcc/imcc.l"
 {
         /* catch all except for state macro */
         return yytext[0];
     }
 	YY_BREAK
 case YY_STATE_EOF(emit):
-#line 663 "compilers/imcc/imcc.l"
+#line 667 "compilers/imcc/imcc.l"
 {
         BEGIN(INITIAL);
 
@@ -4099,18 +4100,18 @@
     }
 	YY_BREAK
 case YY_STATE_EOF(INITIAL):
-#line 674 "compilers/imcc/imcc.l"
+#line 678 "compilers/imcc/imcc.l"
 yyterminate();
 	YY_BREAK
 case 135:
 YY_RULE_SETUP
-#line 676 "compilers/imcc/imcc.l"
+#line 680 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, ENDM);
 	YY_BREAK
 case 136:
 /* rule 136 can match eol */
 YY_RULE_SETUP
-#line 678 "compilers/imcc/imcc.l"
+#line 682 "compilers/imcc/imcc.l"
 {
         IMCC_INFO(interp)->line++;
         DUP_AND_RET(valp, '\n');
@@ -4118,12 +4119,12 @@
 	YY_BREAK
 case 137:
 YY_RULE_SETUP
-#line 683 "compilers/imcc/imcc.l"
+#line 687 "compilers/imcc/imcc.l"
 return LABEL;
 	YY_BREAK
 case 138:
 YY_RULE_SETUP
-#line 685 "compilers/imcc/imcc.l"
+#line 689 "compilers/imcc/imcc.l"
 {
 
         if (yylex(valp,yyscanner,interp) != LABEL)
@@ -4149,7 +4150,7 @@
 	YY_BREAK
 case 139:
 YY_RULE_SETUP
-#line 708 "compilers/imcc/imcc.l"
+#line 712 "compilers/imcc/imcc.l"
 {
         if (valp) {
             const size_t len = strlen(IMCC_INFO(interp)->cur_macro_name) + yyleng + 12;
@@ -4166,39 +4167,39 @@
 	YY_BREAK
 case 140:
 YY_RULE_SETUP
-#line 722 "compilers/imcc/imcc.l"
+#line 726 "compilers/imcc/imcc.l"
 /* skip leading ws */;
 	YY_BREAK
 case 141:
 YY_RULE_SETUP
-#line 723 "compilers/imcc/imcc.l"
+#line 727 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, ' ');
 	YY_BREAK
 case 142:
 YY_RULE_SETUP
-#line 724 "compilers/imcc/imcc.l"
+#line 728 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, IDENTIFIER);
 	YY_BREAK
 case 143:
 YY_RULE_SETUP
-#line 725 "compilers/imcc/imcc.l"
+#line 729 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, MACRO);
 	YY_BREAK
 case 144:
 YY_RULE_SETUP
-#line 726 "compilers/imcc/imcc.l"
+#line 730 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, yytext[0]);
 	YY_BREAK
 case YY_STATE_EOF(macro):
-#line 727 "compilers/imcc/imcc.l"
+#line 731 "compilers/imcc/imcc.l"
 yyterminate();
 	YY_BREAK
 case 145:
 YY_RULE_SETUP
-#line 729 "compilers/imcc/imcc.l"
+#line 733 "compilers/imcc/imcc.l"
 ECHO;
 	YY_BREAK
-#line 4202 "compilers/imcc/imclexer.c"
+#line 4203 "compilers/imcc/imclexer.c"
 case YY_STATE_EOF(pod):
 case YY_STATE_EOF(cmt1):
 case YY_STATE_EOF(cmt2):
@@ -4462,14 +4463,6 @@
 	else
 		ret_val = EOB_ACT_CONTINUE_SCAN;
 
-	if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
-		/* Extend the array by 50%, plus the number we really need. */
-		yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
-		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
-		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
-			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
-	}
-
 	yyg->yy_n_chars += number_to_move;
 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
@@ -4897,9 +4890,7 @@
 		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
 								(num_to_alloc * sizeof(struct yy_buffer_state*)
 								, yyscanner);
-		if ( ! yyg->yy_buffer_stack )
-			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-								  
+		
 		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
 				
 		yyg->yy_buffer_stack_max = num_to_alloc;
@@ -4917,8 +4908,6 @@
 								(yyg->yy_buffer_stack,
 								num_to_alloc * sizeof(struct yy_buffer_state*)
 								, yyscanner);
-		if ( ! yyg->yy_buffer_stack )
-			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
 
 		/* zero only the new slots.*/
 		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -5029,7 +5018,8 @@
 			yyg->yy_start_stack = (int *) yyrealloc((void *) yyg->yy_start_stack,new_size ,yyscanner );
 
 		if ( ! yyg->yy_start_stack )
-			YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
+			YY_FATAL_ERROR(
+			"out of memory expanding start-condition stack" );
 		}
 
 	yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START;
@@ -5253,42 +5243,6 @@
     return yy_init_globals ( *ptr_yy_globals );
 }
 
-/* yylex_init_extra has the same functionality as yylex_init, but follows the
- * convention of taking the scanner as the last argument. Note however, that
- * this is a *pointer* to a scanner, as it will be allocated by this call (and
- * is the reason, too, why this function also must handle its own declaration).
- * The user defined value in the first argument will be available to yyalloc in
- * the yyextra field.
- */
-
-int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
-
-{
-    struct yyguts_t dummy_yyguts;
-
-    yyset_extra (yy_user_defined, &dummy_yyguts);
-
-    if (ptr_yy_globals == NULL){
-        errno = EINVAL;
-        return 1;
-    }
-	
-    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
-	
-    if (*ptr_yy_globals == NULL){
-        errno = ENOMEM;
-        return 1;
-    }
-    
-    /* By setting to 0xAA, we expose bugs in
-    yy_init_globals. Leave at 0x00 for releases. */
-    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
-    
-    yyset_extra (yy_user_defined, *ptr_yy_globals);
-    
-    return yy_init_globals ( *ptr_yy_globals );
-}
-
 static int yy_init_globals (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -5400,7 +5354,7 @@
 
 #define YYTABLES_NAME "yytables"
 
-#line 729 "compilers/imcc/imcc.l"
+#line 733 "compilers/imcc/imcc.l"
 
 
 

Reply via email to