DIR=`mktemp -d` cd $DIR for f in {0,1,2,3,4}{0,1,2,3,4,5,6,7,8,9} do echo $f touch f${f}{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}{0,1,2, 3,4,5,6,7,8,9} done cd $DIR ls * <segfault>
This sounds familiar: http://sources.redhat.com/bugzilla/show_bug.cgi?id=3253 2006-09-30 Ulrich Drepper <drepper> * posix/glob.c (glob_in_dir): Add some comments and asserts to explain why there are no leaks. 2006-09-25 Jakub Jelinek <jakub> [BZ #3253] * posix/glob.c (glob_in_dir): Don't alloca one struct globlink at a time, rather allocate increasingly bigger arrays of pointers, if possible with alloca, if too large with malloc. http://sourceware.org/cgi-bin/cvsweb.cgi/libc/posix/glob.c.diff?cvsroot=glibc&r1=1.69&r2=1.72
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
With glibc-2.3.4-2.28 and bash-3.0-19.3, on an i386, I get a quite different crash now: #0 __gconv_transform_utf8_internal (step=0x9df9c30, data=0xbf40011c, inptrp=0xbf400110, inend=0x9dfe974 "/tmp.Bqlwb28746/", outbufstart=0x0, irreversible=0xbf400114, do_flush=0, consume_incomplete=1) at ../iconv/skeleton.c:401 #1 0x00180beb in *__GI___mbrtowc (pwc=0xbf40018c, s=0x9dfe964 "*", n=16, ps=0xbf400190) at mbrtowc.c:76 #2 0x080c2fdb in xdupmbstowcs (destp=0xbf4001c8, indicesp=0x0, src=0x9dfe964 "*") at xmbsrtowcs.c:188 #3 0x080c2cc9 in xstrmatch (pattern=0x9dfe964 "*", string=0x9e0c96f "f370729", flags=5) at smatch.c:371 #4 0x080bfe09 in glob_vector (pat=0x9dfe964 "*", dir=0x9dfe970 "/tmp/tmp.Bqlwb28746/", flags=0) at glob.c:489 #5 0x080c060b in glob_filename (pathname=0x9dfe950 "/tmp/tmp.Bqlwb28746/*", flags=0) at glob.c:782 #6 0x08086cb3 in shell_glob_filename ( pathname=0x9e02d10 "/tmp/tmp.Bqlwb28746/*") at pathexp.c:254 #7 0x08083a89 in expand_word_list_internal (list=Variable "list" is not available. ) at subst.c:7200 #8 0x0806a8f2 in execute_command_internal (command=0x9e03090, asynchronous=0, pipe_in=-1, pipe_out=-1, fds_to_close=0x9dfad38) at execute_cmd.c:2797 #9 0x0806c670 in execute_command (command=0x9e03090) at execute_cmd.c:351 #10 0x0805dd7b in reader_loop () at eval.c:146 #11 0x0805ce42 in main (argc=1, argv=0xbff954a4, env=0xbff954ac) at shell.c:714 Bash issue?
Created attachment 144715 [details] bash-segv.patch Patch from Yves Begrand <yves.begrand>: - backported changes appearing in glob_vector() routine on bash-3.0-31 - backported changes brought with patch bash31-016 - removed the use of alloca() routine and associated test, because: from alloca(3): "The alloca function is machine and compiler dependent. On many systems its implementation is buggy. Its use is discouraged" I've mentioned to Yves that it would be better to not make any changes regarding alloca usage, as it would make the codebase drift more from upstream.
Does it fix it? Could you file a separate bug for bash please?
Yes, it fixes it, filed as bug #221381
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2007-0210.html