Netflix / flamescope

FlameScope is a visualization tool for exploring different time ranges as Flame Graphs.
Apache License 2.0
3k stars 168 forks source link

UnboundLocalError when the file is invalid #16

Closed PetterS closed 6 years ago

PetterS commented 6 years ago

Stack trace when trying to open an invalid file:

ERROR: Can't read stack file examples/perf.data.
127.0.0.1 - - [05/Apr/2018 15:21:29] "GET /heatmap/?filename=perf.data&rows=50 HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/google/home/strandmark/source/flamescope/app/views/heatmap.py", line 34, in get_heatmap
    return jsonify(generate_heatmap(filename, rows))
  File "/usr/local/google/home/strandmark/source/flamescope/app/util/heatmap.py", line 107, in generate_heatmap
    o = read_offsets(filename)
  File "/usr/local/google/home/strandmark/source/flamescope/app/util/heatmap.py", line 66, in read_offsets
    f.close()
UnboundLocalError: local variable 'f' referenced before assignment
spiermar commented 6 years ago

@PetterS is this a file that should be read, but isn't? Or a more generic error handling issue? If it's the latter, I just opened another issue to track this.

spiermar commented 6 years ago

https://github.com/Netflix/flamescope/issues/18 is the issue.

PetterS commented 6 years ago

Yes, the file is really invalid.