Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Crash with =~ in script, but not interactively



I was going to make a wrapper script that replaces the :43: in gcc
warnings with +43 so i can open in vim easierly, but ran into some
problems.

#!/bin/zsh
#this makes zsh segfault
if [[ $#@ = 1 ]]; then
	if [[ $1 =~ /?[^/]+:[0-9]+:$ ]]; then
		echo hello
	fi
fi

If i save that in a file and run 'zsh file' it crashes, but if i run
'source file' in an open shell it works as expected. Here's a
backtrace with -g3 -O0

Program received signal SIGSEGV, Segmentation fault.
0x080d0d16 in taddstr (s=0xc93fa008 <Address 0xc93fa008 out of
bounds>) at text.c:68
68	    int sl = strlen(s);
(gdb) bt
#0  0x080d0d16 in taddstr (s=0xc93fa008 <Address 0xc93fa008 out of
bounds>) at text.c:68
#1  0x080d1ce2 in gettext2 (state=0xafb7dc3c) at text.c:538
#2  0x080d1008 in getjobtext (prog=0xa7f11480, c=0xa7f114bc) at text.c:172
#3  0x0807656b in execpline2 (state=0xafb7e22c, pcode=259, how=18,
input=0, output=0, last1=0)
    at exec.c:1481
#4  0x0807597b in execpline (state=0xafb7e22c, slcode=26626, how=18,
last1=0) at exec.c:1275
#5  0x080751df in execlist (state=0xafb7e22c, dont_change_job=0,
exiting=0) at exec.c:1081
#6  0x08074dee in execode (p=0xa7f11480, dont_change_job=0, exiting=0)
at exec.c:939
#7  0x0808ddb6 in loop (toplevel=1, justonce=0) at init.c:181
#8  0x08090f15 in zsh_main (argc=2, argv=0xafb7e384) at init.c:1352
#9  0x0805ead6 in main (argc=Cannot access memory at address 0xffffffff
) at ./main.c:93
(gdb) bt full
#0  0x080d0d16 in taddstr (s=0xc93fa008 <Address 0xc93fa008 out of
bounds>) at text.c:68
	sl = -918577144
	c = 0 '\0'
#1  0x080d1ce2 in gettext2 (state=0xafb7dc3c) at text.c:538
	end = (Wordcode) 0xaa0b5378
	s = (Tstack) 0x0
	n = (Tstack) 0x819bd30
	stack = 0
	code = 959262863
	c1 = {0x815d5ab "=", 0x815d5ad "!=", 0x815d5b0 "<", 0x815d5b2 ">",
0x815d5b4 "-nt",
  0x815d5b8 "-ot", 0x815d5bc "-ef", 0x815d5c0 "-eq", 0x815d5c4 "-ne",
0x815d5c8 "-lt",
  0x815d5cc "-gt", 0x815d5d0 "-le", 0x815d5d4 "-ge", 0x815d5d8 "=~"}
#2  0x080d1008 in getjobtext (prog=0xa7f11480, c=0xa7f114bc) at text.c:172
	s = {prog = 0xa7f11480, pc = 0xa7f11534,
  strs = 0xa7f11524 "/\224\217\206/\220+:\2170-9\220+:\205"}
	jbuf = "if [[ \205\204@ = 1 ]]; then; if [[ \2051 =~
/\224\217\206/\220+:\2170-9\220+:\205 ]]; then; echo hello; \005rE "
#3  0x0807656b in execpline2 (state=0xafb7e22c, pcode=259, how=18,
input=0, output=0, last1=0)
    at exec.c:1481
	pid = 134828847
	pipes = {2, -1346904904}
#4  0x0807597b in execpline (state=0xafb7e22c, slcode=26626, how=18,
last1=0) at exec.c:1275
	ipipe = {0, 0}
	opipe = {0, 0}
	pj = 0
	newjob = 1
	old_simple_pline = 0
	slflags = 0
	code = 259
---Type <return> to continue, or q <return> to quit---
	lastwj = 0
	lpforked = 0
#5  0x080751df in execlist (state=0xafb7e22c, dont_change_job=0,
exiting=0) at exec.c:1081
	donedebug = 0
	next = (Wordcode) 0xa7f11520
	code = 26626
	ret = -1346903576
	cj = 0
	csp = 0
	ltype = 18
	old_pline_level = 0
	old_list_pipe = 0
	oldlineno = 8
	oldnoerrexit = 0
	donetrap = 0
#6  0x08074dee in execode (p=0xa7f11480, dont_change_job=0, exiting=0)
at exec.c:939
	s = {prog = 0xa7f11480, pc = 0xa7f114bc,
  strs = 0xa7f11524 "/\224\217\206/\220+:\2170-9\220+:\205"}
#7  0x0808ddb6 in loop (toplevel=1, justonce=0) at init.c:181
	toksav = 1
	prog = (Eprog) 0xa7f11480
#8  0x08090f15 in zsh_main (argc=2, argv=0xafb7e384) at init.c:1352
	t = (char **) 0xafb7e38c
	t0 = 157
#9  0x0805ead6 in main (argc=Cannot access memory at address 0xffffffff
) at ./main.c:93
No locals.

Using revision 'Based on 24334: Documentation for run-help
improvements.' which is currently the latest.

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author