{"action":"closed","issue":{"url":"https://api.github.com/repos/google/trace-viewer/issues/267","labels_url":"https://api.github.com/repos/google/trace-viewer/issues/267/labels{/name}","comments_url":"https://api.github.com/repos/google/trace-viewer/issues/267/comments","events_url":"https://api.github.com/repos/google/trace-viewer/issues/267/events","html_url":"https://github.com/google/trace-viewer/issues/267","id":43544749,"number":267,"title":"VLog handling should verify the stack is not empty before removing entries.","user":{"login":"natduca","id":412396,"avatar_url":"https://avatars.githubusercontent.com/u/412396?v=3","gravatar_id":"","url":"https://api.github.com/users/natduca","html_url":"https://github.com/natduca","followers_url":"https://api.github.com/users/natduca/followers","following_url":"https://api.github.com/users/natduca/following{/other_user}","gists_url":"https://api.github.com/users/natduca/gists{/gist_id}","starred_url":"https://api.github.com/users/natduca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natduca/subscriptions","organizations_url":"https://api.github.com/users/natduca/orgs","repos_url":"https://api.github.com/users/natduca/repos","events_url":"https://api.github.com/users/natduca/events{/privacy}","received_events_url":"https://api.github.com/users/natduca/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/trace-viewer/labels/Bug","name":"Bug","color":"fc2929"},{"url":"https://api.github.com/repos/google/trace-viewer/labels/P2","name":"P2","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-09-22T20:09:45Z","updated_at":"2015-08-04T16:36:15Z","closed_at":"2015-08-04T16:36:15Z","body":"_From [dsinclair@chromium.org](https://code.google.com/u/dsinclair@chromium.org/) on June 24, 2013 09:38:31_\n\nI noticed that in TraceLog::AddTraceEventWithThreadIdAndTimestamp, when an end event is sent with the VLOG flag, it blindly attempts to access and pop off the stack, without checking whether the stack is empty first.\r\n\r\nif (phase == TRACE_EVENT_PHASE_END && trace_options_ & ECHO_TO_VLOG) {\r\n    duration = timestamp - thread_event_start_times_[thread_id].top();\r\n    thread_event_start_times_[thread_id].pop();\r\n  }\r\n\r\nSince stack::top/stack::pop don't have a specified behavior in the case of an empty stack, I think we should be checking, just to be safe.\n\n_Original issue: http://code.google.com/p/trace-viewer/issues/detail?id=261_"}}