grafana / pyroscope

Continuous Profiling Platform. Debug performance issues down to a single line of code
https://grafana.com/oss/pyroscope/
GNU Affero General Public License v3.0
9.66k stars 577 forks source link

fix(ebpf): fix issue when a cls arg is a cell #3280

Closed korniltsev closed 2 months ago

korniltsev commented 2 months ago

Fixes "invalid utf string" issue in our dev cluster.

The issue was caused by ebpf profiler type confusing - trying to use PyCellObject as PyTypeObject

In addition fixes issue when first argument name is incorrectly detected by zeroing the arg name buffer. (previously if could contain garbage from previous frame)

korniltsev commented 2 months ago

I preproduced the issue here https://github.com/pyroscope-io/pyroscope-ebpf-testdata/blob/fc63fce7e3e3995d305cdfab0efc239e5632c164/rideshare-flask-no-pip/lib/server.py#L28-L43

korniltsev commented 2 months ago

And I also spotted this for the first time 🙂

Yesterday I found another issue with the way the code detects class name.

f_code->co_varnames may contain same name multiple times. It may look like ('self', 'foo', 'bar', 'self') and f_localsplus[0] == NULL and f_localsplus[3] == 0x7f....