NetBSD Problem Report #57056

From www@netbsd.org  Thu Oct 13 23:53:45 2022
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 026DA1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 13 Oct 2022 23:53:45 +0000 (UTC)
Message-Id: <20221013235343.CE4F61A923A@mollari.NetBSD.org>
Date: Thu, 13 Oct 2022 23:53:43 +0000 (UTC)
From: vms@usa.com
Reply-To: vms@usa.com
To: gnats-bugs@NetBSD.org
Subject: spim and xspim run in an endless loop due to a bug in CPU/scanner.l
X-Send-Pr-Version: www-1.0

>Number:         57056
>Category:       pkg
>Synopsis:       spim and xspim run in an endless loop due to a bug in CPU/scanner.l
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 13 23:55:00 +0000 2022
>Originator:     .:VMS:.
>Release:        9.3 current Thu Oct 13 23:40:26 UTC 2022
>Organization:
hahahah
>Environment:
NetBSD localhost 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
spim and xspim run an endless loop because a bug related with flex.

It seems to use flex to parse assembly instructions, as it's a mips assembly interpreter, you give it asm code and it executes it.

The bug is at file CPU/scanner.l at line 319

#if (YY_FLEX_MAJOR_VERSION==2 && YY_FLEX_MINOR_VERSION==5 && YY_FLEX_SUBMINOR_VERSION>=33)
  /* flex 2.5.33 flipped the polarity of this flag (sigh) */
  yy_init = 0;                                                                                                     
#else
  yy_init = 1;    


This is the bug

it seems flex versions prior to that one needed that variable to be 1 instead of 0, the thing is the NetBSD flex's version does not match with this #if directive so yy_init is set to 1 when it should be a 0.

in my case I've just typed 'make' to download the source code and removed this stuff and just put 'yy_init = 0;'

this solves the problem and now xspim seems to work and I assume spim will do too.

I have no idea on how to make a patch file so I can't help more than that.

Anyways that's the source of the bug and it's avoided by just setting yy_init to 0.

Note that it's mlelstv who spotted the bug as I would have no idea if not :D so thank him instead, I'm just sending the pr so the mantainer can fix that.


>How-To-Repeat:
install spim and run spim or xspim, it won't work.

>Fix:
set yy_init to 0 or fix that #if directive to match that flex version and possible future ones 

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2022 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.