# How to debug profiler warning about invalid memory location

**URL:** <https://discourse.julialang.org/t/how-to-debug-profiler-warning-about-invalid-memory-location/40477>\
**Category:** Performance\
**Tags:** profiling\
**Created:** [May 30, 2020, 5:41pm UTC](https://discourse.julialang.org/t/how-to-debug-profiler-warning-about-invalid-memory-location/40477 "2020-05-30T17:41:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alemelis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alemelis/32/208433_2.png) [@alemelis](https://discourse.julialang.org/u/alemelis)\
**Post date:** [May 30, 2020, 5:41pm UTC](https://discourse.julialang.org/t/how-to-debug-profiler-warning-about-invalid-memory-location/40477/1 "2020-05-30T17:41:00Z")

</div>

Hello, I was curious about profiling (and learning how to do it) a code I wrote. Reading the official guide ([here](https://docs.julialang.org/en/v1/manual/profile/index.html#Memory-allocation-analysis-1)), I came across the [ProfileView.jl](https://github.com/timholy/ProfileView.jl) package.

I simply used the `@profview` macro provided by the package and I can indeed obtain the flame graph and learn about my code execution. However, I also get a number of warnings

```julia
WARNING: profiler attempt to access an invalid memory location

```

is this indicating some sort of memory leak in my code? Couldn’t find any reference to this in any documentation

---

<div class="post-metadata">

**Author:** ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Post date:** [June 11, 2020, 1:28pm UTC](https://discourse.julialang.org/t/how-to-debug-profiler-warning-about-invalid-memory-location/40477/2 "2020-06-11T13:28:18Z")

</div>

I’ve just run into this, and I’m wondering what this means, too.

It’s emitted from here: [https://github.com/JuliaLang/julia/blob/38f2c594c49cec46d38be6dd614a5592582a3016/src/signals-unix.c#L692](https://github.com/JuliaLang/julia/blob/38f2c594c49cec46d38be6dd614a5592582a3016/src/signals-unix.c#L692)

And from [https://linux.die.net/man/3/sigsetjmp](https://linux.die.net/man/3/sigsetjmp)

> **setjmp** () and **sigsetjmp** () return 0 if returning directly, and nonzero when returning from **[longjmp](https://linux.die.net/man/3/longjmp)** (3) or **[siglongjmp](https://linux.die.net/man/3/siglongjmp)** (3) using the saved context.

And from wikipedia

> The (apparent) [return value](https://en.wikipedia.org/wiki/Return_value) from `setjmp` indicates whether control reached that point normally (zero) or from a call to `longjmp` (nonzero). This leads to a common [idiom](https://en.wikipedia.org/wiki/Programming_idiom): `if( setjmp(x) ){/* handle longjmp(x) */}` .

That’s all I got. Not sure where the longjmp in question is.

---

<div class="post-metadata">

**Author:** ![gideonsimpson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gideonsimpson/32/1928_2.png) [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Post date:** [August 30, 2020, 6:35pm UTC](https://discourse.julialang.org/t/how-to-debug-profiler-warning-about-invalid-memory-location/40477/3 "2020-08-30T18:35:02Z")

</div>

I’m getting the same warning with my code and regular `Profile` (without any visualization). I’m using Julia 1.5.1 on MacOS.

---

<div class="post-metadata">

**Author:** ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)\
**Post date:** [August 30, 2020, 10:18pm UTC](https://discourse.julialang.org/t/how-to-debug-profiler-warning-about-invalid-memory-location/40477/4 "2020-08-30T22:18:19Z")

</div>

I have also seen this; could it have to do with multithreading?

---

<div class="post-metadata">

**Author:** ![gideonsimpson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gideonsimpson/32/1928_2.png) [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Post date:** [August 30, 2020, 10:38pm UTC](https://discourse.julialang.org/t/how-to-debug-profiler-warning-about-invalid-memory-location/40477/5 "2020-08-30T22:38:50Z")

</div>

The code I’m using doesn’t make explicit use of Threads, though maybe there’s something going on under the hood with one of the subordinate packages.

---

<div class="post-metadata">

**Author:** ![MackHarry](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mackharry/32/13943_2.png) [@MackHarry](https://discourse.julialang.org/u/MackHarry)\
**Post date:** [October 12, 2020, 4:08pm UTC](https://discourse.julialang.org/t/how-to-debug-profiler-warning-about-invalid-memory-location/40477/6 "2020-10-12T16:08:12Z")

</div>

I’m getting the same warning when trying to profile a call to `save` for a figure.
