POV-Ray

The Persistence of Vision Raytracer (POV-Ray).

This is the legacy Bug Tracking System for the POV-Ray project. Bugs listed here are being migrated to our github issue tracker. Please refer to that for new reports or updates to existing ones on this system.

Tasklist

FS#336 - #fopen w/o OPEN_TYPE crash povray (segfault)

Attached to Project: POV-Ray
Opened by Pietro Bernardi (bpietro) - Sunday, 06 November 2016, 12:47 GMT
Last edited by William F Pokorny (wfpokorny) - Friday, 25 November 2016, 16:07 GMT
Task Type Definite Bug
Category Backend → Parser/SDL
Status Closed
Assigned To Christoph Lipka (clipka)
Operating System All
Severity Low
Priority Normal
Reported Version 3.70 release
Due in Version 3.71 release
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

#fopen directive w/o OPEN_TYPE (yeah, I forgot it, some other languages have ‘read’ as default value)

expected behavior:
Parse error msg “line XXX, OPEN_TYPE missing in #fopen directive”, then stop.

observed behavior:
crash - Segfault err (core dump) in Parsing stage

minimal working example attached

This task depends upon

Closed by  William F Pokorny (wfpokorny)
Friday, 25 November 2016, 16:07 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed with git commit d62de5c was Christoph Lipka, Sun Nov 6 15:58:06 2016 +0100, message: Fix FlySpray task 336 (http://bugs.povray.org/task/336).

My testing confirms and closing as of github pre-release Nov 25, 2016.
Comment by Christoph Lipka (clipka) - Sunday, 06 November 2016, 14:55 GMT

Solving this issue is only semi-trivial, as "#read" may be perfectly valid smack within a "#fopen" statement, as exemplified by the following code:

#fopen ControlFile "control.txt" read

#fopen OutFile "out.txt"
  #read (ControlFile,AppendFlag)
  #if (AppendFlag)
    append
  #else
    write
  #end
...
#fclose OutFile

#fclose ControlFile

Problems arise if a "#read", "#write" or (untested) "#fclose" statement thus embedded in a "#fopen" statement (or after an incomplete "#fopen" statement) references the same file handle, as in this case the file handle will not have been properly initialized yet.

I'll add a safeguard for such cases so that you get a graceful error rather than a hard crash.

Comment by Christoph Lipka (clipka) - Sunday, 06 November 2016, 15:00 GMT
  • Field changed: Status (Investigating → Submitted to codebase)
  • Field changed: Percent Complete (90% → 100%)

Should be fixed with commit d62de5c.

Loading...