[futurebasic] A bug in FutureBasic_5_7_97

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2017 : Group Archive : Group : All Groups

From: <fblistserve@...>
Date: Mon, 13 Feb 2017 14:40:44 -0800
Walter reported a bug to me backchannel. He supplied a good description and code to reproduce it:
On Feb 13, 2017, Walter wrote:

I want to report of bug with FutureBasic_5_7_97 – this happens when the compiler encounters a bug in the source code and reports back that it has occurred at a specific line number. When you click on that message, instead of taking you to the appropriate line, it takes you to another line that is somewhere around 20 lines beyond the actual line.

<snip> I have induced a particular bug at line 100, and when I am running FutureBasic_5_7_97, it reports the bug at line 100 but actually goes to line 117 in the editor. I have noticed that this offset varies from file to file, and on some files it seems to not be a problem – that's why I sent you this particular file so you can see what I'm talking about.

FBtoC’s error message is accurate as the stray ’tttt’ text is on line 100 but the editor, as Walter notes, points to some line 15 to 20 lines beyond line 100.

FBtoC: translating Add prefix or suffix.bas
FBtoC: build settings from FBtoC preferences
FBtoC: FB's runtime translated in: 4906 milliseconds
** Unknown variable, command or Toolbox name in line 100 of Add prefix or suffix.bas: 'tttt'
100: tttt
Translation failed with 1  error

Typically this is a fairly ordinary bug but want to mention some thoughts:

[1] The bug is fixed for the next release of FB assuming everyone can wait. Thanks to Walter’s input only a few minutes of testing revealed the bug.

[2] The bug itself is a consequence of global variable use in a multi-threaded application. The dispatched asynchronous thread( the one which notifies the editor of an error ) incorrectly captured the value of a global( which holds the error line number ) within the block but the global changes ( because it reflects current line number which increases as the translation continues ) several times before the block sends the notification to the editor. 

Perhaps an old song but a reminder: global variable usage can bite back. Dealing with them in a single-threaded app is child’s play but potentially unsolvable with multi-threads.

Thanks again to Walter for making the effort to supply all the information in one email. It helps me a lot on several levels.