bugGneural Network - Bugs: bug #49220, Parser.c needs better error...

 
 

bug #49220: Parser.c needs better error handling.

Submitted by:  Ray Dillinger <rayd>
Submitted on:  Thu 29 Sep 2016 01:51:15 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Ray Dillinger <rayd>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 29 Oct 2016 08:40:07 AM UTC, comment #2:

After fairly exhaustive testing I'm closing this one. The usage pattern is clear, and the error messages are so explicit that it is possible to learn the configuration language from error messages alone. Possible buffer overruns are shut down good and hard.

Also there is absolutely nothing save allocation failure that can cause the parser to bail without an error message; Even allocation failure is handled correctly on systems where it is possible by normal means to detect the failure before crashing.

grrf... Linux as of the current kernel has "optimistic" memory allocation. That means checking for allocation failure (did 'malloc' return NULL??) doesn't work. 'malloc' can return non-NULL when no memory is available, and then the program will crash when you try to write it. This prevents detecting errors (and therefore prevents error handling). However, when the kernel shuts the process down it prints a generic error message, so we get half-credit just for showing up.

I could still install a signal handler, but with memory allocation failures in the parser there's really nothing for it to do except print an error message and quit. Memory allocation failures elsewhere might have a correct response that prints out the output file (with resume-training information) but that will be a different task.

Ray Dillinger <rayd>
Project MemberIn charge of this item.
Thu 20 Oct 2016 06:11:55 AM UTC, comment #1:

I've just checked in a parser for a configuration language for the 'nnet' representation for neural networks. Please beat on it and test it. It isn't supposed to ever 'crash' - when it encounters any error it makes a controlled exit with an error message. The error messages it generates when something doesn't parse are intended to be so explicit that you can literally learn the language from them without recourse to documentation. It also gives warning messages when the script it's reading does something that's usually a mistake.

At this time it handles topology only - it allows nodes and connections and weights to be defined. Still to add to the new parser, these scripts ought to also have sections for (at least) Training and Data. So the parser is ready for test, but still incomplete. I'm not closing this yet because the language isn't complete yet, but I'm going to mark it as 75% done.

There is a matching new facility (in 'save.c') that takes a nnet and writes out its topology in the same language. The output of the writer, when read by the parser, will produce a network of the same weights, topology and firing sequence.

Right now the executable named 'nnet' simply reads a configuration file producing a network, then writes out the network in the same language.

Ray Dillinger <rayd>
Project MemberIn charge of this item.
Thu 29 Sep 2016 01:51:15 AM UTC, original submission:

When parser.c attempts to read a number in the program source code, it does so using fscanf with a numeric format argument. It therefore invokes undefined behavior (aka, the curse of the Nasal Demons) rather than exiting, if the characters it reads are not a number.

Relying on Nasal Demons to perform an exit from a compiler is bad form, because they might do worse things than just exit.

Good error handling means detecting the error whenever a program is invalid, producing sensible error messages giving the specific program line and column where the error was detected, and then performing a controlled exit without invoking Nasal Demons.

Ray Dillinger <rayd>
Project MemberIn charge of this item.

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rayd (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 29 Oct 2016 08:40:07 AM UTCraydStatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Thu 20 Oct 2016 06:11:55 AM UTCraydStatusNone=>Ready For Test
      Assigned toNone=>rayd

    Back to the top


    Powered by Savane 3.1-cleanup1