From owner-freebsd-questions Thu Jun 6 14:53:36 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mail3.aracnet.com (mail3.aracnet.com [216.99.193.38]) by hub.freebsd.org (Postfix) with ESMTP id 1CEDC37B40A for ; Thu, 6 Jun 2002 14:53:08 -0700 (PDT) Received: from aracnet.com (216-99-194-142.dial.spiritone.com [216.99.194.142]) by mail3.aracnet.com (8.12.3/8.12.1) with ESMTP id g56Lr5CW018227; Thu, 6 Jun 2002 14:53:06 -0700 Message-ID: <3CFF6B01.3080500@aracnet.com> Date: Thu, 06 Jun 2002 14:00:33 +0000 From: henry tieman User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0rc1) Gecko/20020509 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-questions@FreeBSD.ORG Subject: gcc -O and xsane crash Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I found a compiler problem with optimizations in Xsane-0.85. Gcc generates a test against an uninitialised variable in the function preview_autoselect_scanarea which can cause a memory overrun. Turning off optimazations cures the problem. The details are: the second loop in the function generates a stopping comparison of (x < y), y is a register variable, and not (x < p->image_width) like the source code says. I used ddd's "Machine Code Window" to see this. y is uninitialized at this point so the memory overrun seems to depend on the picture being scanned. Since I have a workaround, I'm not too interested in solving this myself. I just thought it would be helpfull to other users to pass the information on. I had a friend in collage that always complained the compiler was wrong and he was never right. So I really really hate to say it myself. I should probably include I'm using FreeBSD 4.5 with gcc version 2.95.3 20010315 (release) [FreeBSD] -- Henry Tieman You may have to remove the _NOSPAM to reply to this message. Objects in the mirror are closer than they appear. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message