fillPath consumes all memory when the path has an arc with out of range arguments
kwhitefoot opened this issue · comments
This program runs until killed with out of memory. Of course the arguments to the arc command are far out of range but I would expect a catchable exception instead of an out of memory crash. I suppose it is a similar problem to #403 and #392.
import pixie, chroma
let
image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
let
pathStr = """
L 3473901.0 1136732.75
A 31888.0 31888.0 0 0 1 3493390.25 1076022.375
L 32563.0 -2081.0"""
var
paint = newPaint(SolidPaint)
paint.color = color(255, 255, 255, 255)
let
path = parsePath(pathStr)
fillPath(image,
path,
paint,
mat3(),
NonZero)
Result:
$ ulimit -Sv unlimited; /usr/bin/time -v examples//test_mem6
Command terminated by signal 9
Command being timed: "examples//test_mem6"
User time (seconds): 154.55
System time (seconds): 3.02
Percent of CPU this job got: 97%
Elapsed (wall clock) time (h:mm:ss or m:ss): 2:41.19
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 6226992
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 19
Minor (reclaiming a frame) page faults: 2272969
Voluntary context switches: 2120
Involuntary context switches: 2021
Swaps: 0
File system inputs: 4192
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
This is another float32 precision issue. Addressed in latest merged PR per the above test. Is it perfect though? Unclear, I'm sure there are adversarial paths out there that can still misbehave, we'll see tho.