Skip to content

IO in threads corrupts heap even when protected #18962

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

Closed
RalphAS opened this issue Oct 16, 2016 · 4 comments
Closed

IO in threads corrupts heap even when protected #18962

RalphAS opened this issue Oct 16, 2016 · 4 comments

Comments

@RalphAS
Copy link

RalphAS commented Oct 16, 2016

While experimenting with multithreading, it is helpful to have constructs like

lock(mylock)
println(message)
unlock(mylock)

in the thread functions, where mylock is a Mutex or SpinLock. Although this works most of the time, I find that programs which do a lot of allocation often segfault (in GC code) when such constructs are present. Are such locks known to be insufficient to protect thread-unsafe code? If not, I can provide gists of code and tracebacks.

Julia Version 0.6.0-dev.787
Commit c71f205 (2016-09-26 16:28 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)

Also seen in v0.5.0

@yuyichao
Copy link
Contributor

In general locking is not enough to make IO thread safe.

@vtjnash
Copy link
Member

vtjnash commented Oct 16, 2016

Dup #15620. This is partly why threading support is still alpha/experimental

@vtjnash vtjnash closed this as completed Oct 16, 2016
@RalphAS
Copy link
Author

RalphAS commented Oct 16, 2016

I'm trying to help you make it solid! Anyway, I think this may differ from #15620 because the crash is a
real segfault (i.e. invalid memory access) and often occurs after the thread loop has completed - hence the issue title.

Here is example code and a valgrind log. Commenting out the print statement in the thread loop suppresses the problem (AFAICT).

@yuyichao
Copy link
Contributor

Valgrind is pretty useless for this AFAICT. I don't think this is really a dup of #15620 but it's still dup of open thread safe issues.

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

No branches or pull requests

3 participants