From owner-freebsd-current@FreeBSD.ORG Tue Apr 13 07:48:05 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76B84106566B for ; Tue, 13 Apr 2010 07:48:05 +0000 (UTC) (envelope-from hizel@vyborg.ru) Received: from mail.vyborg.ru (mail.vyborg.ru [195.177.105.12]) by mx1.freebsd.org (Postfix) with ESMTP id 0BED18FC13 for ; Tue, 13 Apr 2010 07:48:04 +0000 (UTC) Received: from hzwork.vyborg.ru (o.vyborg.ru [195.177.104.22]) by mail.vyborg.ru (8.14.3/8.14.3) with ESMTP id o3D7nPGQ078296 for ; Tue, 13 Apr 2010 11:49:25 +0400 (MSD) (envelope-from hizel@vyborg.ru) Date: Tue, 13 Apr 2010 11:48:03 +0400 From: Hizel Ildar To: freebsd-current@freebsd.org Message-ID: <20100413114803.784e2ab7@hzwork.vyborg.ru> In-Reply-To: <20100413095350.3e74bb85@hzwork.vyborg.ru> References: <20100411001454.GO73901@bunrab.catwhisker.org> <20100413095350.3e74bb85@hzwork.vyborg.ru> X-Mailer: Claws Mail 3.7.5 (GTK+ 2.20.0; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: SIGSEGV in dc, at bcode.c:277 (function reset_bmachine()) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Apr 2010 07:48:05 -0000 =D0=92 Tue, 13 Apr 2010 09:53:50 +0400 Hizel Ildar =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > =D0=92 Sat, 10 Apr 2010 17:14:54 -0700 > David Wolfskill =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >=20 > > As these things go, this probably isn't as critical as most thinsg > > disussed on this list, but I happened to notice it today, built a > > debugging world and at least cornered the annoying little varmint. > >=20 > > Sorry; no patch at this time. :-( > >=20 > > Here's how to reproduce it: while running CURRENT, invoke dc(1) > > using the command-line expression-soecification ("-e ..."), thus: > >=20 > > freebeast(9.0-C)[2] dc -e "6 2/p" > > Segmentation fault (core dumped) > > freebeast(9.0-C)[3]=20 > >=20 > > This was running: > >=20 > > FreeBSD freebeast.catwhisker.org 9.0-CURRENT FreeBSD 9.0-CURRENT #1 > > r206447: Sat Apr 10 14:49:56 PDT 2010 > > root@freebeast.catwhisker.org:/common/S1/obj/usr/src/sys/GENERIC > > i386 > >=20 >=20 > Also, when using the option -f file must be core dump :( >=20 > foo# echo '6 2/p' > /tmp/test > foo# dc -f /tmp/test > Segmentation fault (core dumped) > foo# gdb /usr/bin/dc dc.core=20 > GNU gdb 6.1.1 [FreeBSD] > Copyright 2004 Free Software Foundation, Inc. > GDB is free software, covered by the GNU General Public License, and > you are welcome to change it and/or distribute copies of it under > certain conditions. Type "show copying" to see the conditions. > There is absolutely no warranty for GDB. Type "show warranty" for > details. This GDB was configured as "i386-marcel-freebsd"... > Core was generated by `dc'. > Program terminated with signal 11, Segmentation fault. > Reading symbols from /lib/libcrypto.so.6...done. > Loaded symbols for /lib/libcrypto.so.6 > Reading symbols from /lib/libc.so.7...done. > Loaded symbols for /lib/libc.so.7 > Reading symbols from /libexec/ld-elf.so.1...done. > Loaded symbols for /libexec/ld-elf.so.1 > #0 0x08049818 in reset_bmachine (src=3D0x804fc48) > at /usr/src/usr.bin/dc/bcode.c:277 277 > bmachine.readstack[0] =3D *src; (gdb) bt > #0 0x08049818 in reset_bmachine (src=3D0x804fc48) > at /usr/src/usr.bin/dc/bcode.c:277 #1 0x0804947e in procfile > (fname=3D0xbfbfea22 "/tmp/test") at /usr/src/usr.bin/dc/dc.c:75 #2 > 0x0804951f in main (argc=3D3, argv=3D0xbfbfe8fc) > at /usr/src/usr.bin/dc/dc.c:96 (gdb) quit foo# uname -a > FreeBSD foo.vyborg.ru 9.0-CURRENT FreeBSD 9.0-CURRENT #1: Sun Apr 11 > 21:00:05 MSD 2010 > root@foo.vyborg.ru:/usr/obj/usr/src/sys/GENERIC i386 >=20 My patch: foo# diff -ruN dc.c.orig dc.c --- dc.c.orig 2010-04-13 10:33:22.000000000 +0400 +++ dc.c 2010-04-13 11:44:18.000000000 +0400 @@ -87,12 +87,16 @@ while ((ch =3D getopt_long(argc, argv, "e:f:Vx", long_options, NULL= )) !=3D -1) { switch (ch) { case 'e': + if(!preproc_done) + init_bmachine(extended_regs); src_setstring(&src, optarg); reset_bmachine(&src); eval(); preproc_done =3D true; break; case 'f': + if(!preproc_done) + init_bmachine(extended_regs); procfile(optarg); preproc_done =3D true; break; @@ -114,7 +118,9 @@ argc -=3D optind; argv +=3D optind; =20 - init_bmachine(extended_regs); + if (!preproc_done) + init_bmachine(extended_regs); + setlinebuf(stdout); setlinebuf(stderr); test: foo# dc -f /tmp/test 3 foo# dc -e "6 2/p" 3 foo# dc -e "6 2/p" -f /tmp/test 3 3 foo# dc -e "6 2/p" -f /tmp/test /tmp/test 3 3 3