On Tue, 19 Feb 2008, Denys Vlasenko wrote:

> Here:
>
>               /* "A=a B=$A" case: var_str_list is a list of "A=a" strings
>                * which should be considered before we check variables. */
>               if (var_str_list) {
>
> Does it work again yf you replace "if (var_str_list)" with "if (0)"?

Yes.

> If yes, can you add lots of  bb_error_msg("LINE %d", __LINE__)
> to the body of the "if" and find out where it dies?

Modified ash r21030 as in attachment, produces this output:

# for B in $VAR;do echo $B;done
sh: LINE 5907
sh: LINE 5914: name_len=4
sh: LINE 5916
sh (pid 76) segfaults for page address 20188000 at pc 355a06a6


Cheers,

-- 
Cristian
--- shell/ash.c	2008-02-19 13:19:32.000000000 +0100
+++ shell/ash.c	2008-02-19 15:14:33.000000000 +0100
@@ -5904,32 +5904,47 @@
 		p = num ? shellparam.p[num - 1] : arg0;
 		goto value;
 	default:
+		bb_error_msg("LINE %d", __LINE__);
 		/* NB: name has form "VAR=..." */
 
 		/* "A=a B=$A" case: var_str_list is a list of "A=a" strings
 		 * which should be considered before we check variables. */
 		if (var_str_list) {
 			unsigned name_len = (strchrnul(name, '=') - name) + 1;
+			bb_error_msg("LINE %d: name_len=%u", __LINE__, name_len);
 			p = NULL;
+			bb_error_msg("LINE %d", __LINE__);
 			do {
 				char *str = var_str_list->text;
 				char *eq = strchr(str, '=');
+				bb_error_msg("LINE %d", __LINE__);
 				if (!eq) /* stop at first non-assignment */
 					break;
+				bb_error_msg("LINE %d", __LINE__);
 				eq++;
+				bb_error_msg("LINE %d", __LINE__);
 				if (name_len == (eq - str)
 				 && strncmp(str, name, name_len) == 0) {
+					bb_error_msg("LINE %d", __LINE__);
 					p = eq;
 					/* goto value; - WRONG! */
 					/* think "A=1 A=2 B=$A" */
+					bb_error_msg("LINE %d", __LINE__);
 				}
+				bb_error_msg("LINE %d", __LINE__);
 				var_str_list = var_str_list->next;
+				bb_error_msg("LINE %d", __LINE__);
 			} while (var_str_list);
+			bb_error_msg("LINE %d", __LINE__);
 			if (p)
 				goto value;
+			bb_error_msg("LINE %d", __LINE__);
 		}
+		bb_error_msg("LINE %d", __LINE__);
 		p = lookupvar(name);
+		bb_error_msg("LINE %d", __LINE__);
  value:
+		bb_error_msg("LINE %d", __LINE__);
 		if (!p)
 			return -1;
 
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to