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

Segfault in profiler #3971

Closed
ViralBShah opened this issue Aug 7, 2013 · 10 comments · Fixed by #4159
Closed

Segfault in profiler #3971

ViralBShah opened this issue Aug 7, 2013 · 10 comments · Fixed by #4159
Labels
kind:bug Indicates an unexpected problem or unintended behavior system:mac Affects only macOS
Milestone

Comments

@ViralBShah
Copy link
Member

This code crashes in julia, when running in the profiler, inside openblas. This is only on mac and not on linux.
https://gist.github.com/blakejohnson/5600044

@profile for ct=1:10 run_sim(); end

A detailed discussion of this issue began when the profiler was in Profile.jl: timholy/IProfile.jl#14

@ViralBShah
Copy link
Member Author

Cc: @timholy @blakejohnson

@blakejohnson
Copy link
Contributor

I assume we are just moving this issue here?

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 11, 2013

Copying this from the old thread also:

using Profile
@profile let 
              tic()
              n = 10000;
              m = 100;
              l = 10;
              A = zeros(n,m);
              for i=1:n
                  for j=1:m
                      c = rand(10,10);
                      A[i,j] = c[2,5];
                  end
                  h = find(A[i,:].>0.5);
                  for k=1:l
                      c = fft(A[:,l]);
                      d = min(abs(c));
                  end
              end
              toc()
              end;

GDB analysis appears to indicate the crash happens when a timer fires during the prolog of a function call which has dwarf info. Perhaps all C code would need to be compiled with -fasynchronous-unwind-tables to make that work. Somehow gdb usually can get it right (or at least not crash).

@timholy
Copy link
Sponsor Member

timholy commented Aug 11, 2013

Is it fair to guess that gdb is not using libunwind?

@Keno
Copy link
Member

Keno commented Aug 23, 2013

I've ruled out a bug in the libunwind sigreturn implementation by writing a version that suspends/samples the main thread instead. Same problem still occurs unfortunately.

@Keno
Copy link
Member

Keno commented Aug 23, 2013

@vtjnash This may explain the off by one mystery (from Apple's libunwind):

    // if the last line of a function is a "throw" the compile sometimes
    // emits no instructions after the call to __cxa_throw.  This means 
    // the return address is actually the start of the next function.
    // To disambiguate this, back up the pc when we know it is a return
    // address.  
    if ( isReturnAddress ) 
        --pc;

@Keno
Copy link
Member

Keno commented Aug 23, 2013

Looking at their unwinder, I found this:

uint64_t savedRegisters = registers.getRBP() - 8*savedRegistersOffset;

which to me appears invalid if the base pointer has not been adjusted yet.

@Keno
Copy link
Member

Keno commented Aug 23, 2013

Alright, I compiled the latest version of Apple's libunwind, which doesn't segfault, but it also doesn't give any output, so I'm not sure that's better.

@blakejohnson
Copy link
Contributor

@loladiro by latest version of Apple's libunwind, are you referring to this, or to something later?

@Keno
Copy link
Member

Keno commented Aug 24, 2013

Yeah, that's what I'm referring to. I actually managed to figure it out. I'll have a patch shortly.

KristofferC pushed a commit that referenced this issue Jul 26, 2024
Stdlib: Pkg
URL: https://github.com/JuliaLang/Pkg.jl.git
Stdlib branch: master
Julia branch: master
Old commit: 6b4394914
New commit: e4a6723bf
Julia version: 1.12.0-DEV
Pkg version: 1.12.0
Bump invoked by: @IanButterworth
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Pkg.jl@6b43949...e4a6723

```
$ git log --oneline 6b4394914..e4a6723bf
e4a6723bf Use `Base.TOML.Parser{Dates}` for TOML parsing w/ Dates support (#3938)
8c1f45d98 Append bundled depots to places where we empty it during tests (#3807)
2fdfabaf5 Test fixes (#3972)
34bb51ece fix bad depot path setting (#3971)
3715685b9 fix suggestions threshold for printing (#3968)
3f81d6c4d feat: add JULIA_PKG_GC_AUTO env var (#3642)
fad26d7f2 check `project_file` isa String (#3967)
8875120ad fix not hardcoding "Project.toml" when fixing up extensions in manifest (#3851)
90d42a1b0 Make manifest usage log errors non-fatal (#3962)
```

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior system:mac Affects only macOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants