Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Possible for frame entry in stack table to be null #85

Closed
dalehamel opened this issue Aug 14, 2024 · 6 comments · Fixed by #89
Closed

[bug] Possible for frame entry in stack table to be null #85

dalehamel opened this issue Aug 14, 2024 · 6 comments · Fixed by #89

Comments

@dalehamel
Copy link
Contributor

dalehamel commented Aug 14, 2024

A production app generated profiles which failed to load in any version of firefox-profiler we tried. One of our devs filed this issue upstream firefox-devtools/profiler#5074, but I believe the true issue is that the output from vernier is not a valid gecko profile.

The profile does not load in https://vernier.prof either. Here is the profile.

Looking closely at the error, I was able to determine that a thread has an invalid stack table:

    {
      "name": "(2051520)",
      "isMainThread": false,
      "processStartupTime": 995739.389136,
      "registerTime": 995739.389136,
      "pausedRanges": [],
      "pid": 123,
      "tid": 0,
      "frameTable": {
        "address": [],
        "inlineDepth": [],
        "category": [],
        "subcategory": null,
        "func": [],
        "nativeSymbol": [],
        "innerWindowID": [],
        "implementation": [],
        "line": [],
        "column": [],
        "length": 0
      },
      "funcTable": {
        "name": [],
        "isJS": [],
        "relevantForJS": [],
        "resource": [],
        "fileName": [],
        "lineNumber": [],
        "columnNumber": [],
        "length": 0
      },
      "nativeSymbols": {},
      "samples": {
        "stack": [
          0,
          1
        ],
        "weight": [
          1,
          1032
        ],
        "weightType": "samples",
        "length": 2
      },
      "stackTable": {
        "frame": [
          null,
          null
        ],
        "category": [
          2,
          1
        ],
        "subcategory": [
          0,
          0
        ],
        "prefix": [
          null,
          null
        ],
        "length": 2
      },

The root cause seems to be that the "frame" entry itself is somehow "null". This gets input as a numeric index, and ends up exploding in the UI.

If I delete the invalid thread, the profile can now be displayed.

This seems like a legitimate bug in vernier, as we're somehow getting invalid output where the top stack frame references a null value, which is an invalid index into the frame table. The frametable is also empty, as the example shows.

@dalehamel
Copy link
Contributor Author

Note that the profile was generated from the latest released version of vernier, 1.1.1

@Earlopain
Copy link
Contributor

Earlopain commented Aug 16, 2024

I'm encountering the same thing. I'm profiling something with bundler/inline and I believe the issue has something to do with me specifying git dependencies:

# frozen_string_literal: true

require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "rails", github: "rails/rails"
end

This consistently produces a profile I'm unable to load for what I assume are the same reasons as OP. trace.json

I run vernier like so: vernier run --output trace.json -- ruby test.rb. Ruby is 3.3.4

@Earlopain
Copy link
Contributor

Earlopain commented Aug 17, 2024

Reduced it a bit further and it seems to boil down to this:

# frozen_string_literal: true

pid = Process.spawn("sleep", "1")
wait_thr = Process.detach(pid)
wait_thr.join

The issue seems to be with Process.detach. I also have this other case which doesn't terminate when running with vernier (though perhaps a different issue altogether, #82 maybe?):

# frozen_string_literal: true

pid = Process.fork do
  sleep 1
end
wait_thr = Process.detach(pid)
wait_thr.join

@jhawthorn
Copy link
Owner

Thank you both! I just merged #89 which should fix this and released that as 1.1.2

@Earlopain
Copy link
Contributor

This works nicely, thanks!

@dalehamel
Copy link
Contributor Author

@jhawthorn thank you! We'll try it out and report back if it is not resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants