Assertion failed or Segmentation Fault when creating lots of threads. #154

Closed
davrodpin opened this Issue Jan 6, 2010 · 2 comments

3 participants

@davrodpin

I did compile rubinius without llvm on a CenOS 5.4 and create a program to spawn lots of threads.

Whem it reaches a certain number os threads, raises an segmentation fault or in some cases, even before create the threads an error occurs. Some specific information about the problem:

  • test_threads.rb
NTHREADS=ARGV[0]

$pool = []

NTHREADS.to_i.times do |n|
  $pool << Thread.new do
    loop { sleep 0.025 }
  end
end

loop do
  puts "+ #{$pool.size.to_s} threads running."
  sleep 1
end

  • Machine

CentOS 5.4
gcc-c++-4.1.2-46.el5
gcc-4.1.2-46.el5
libgcc-4.1.2-46.el5
libstdc++-devel-4.1.2-46.el5libstdc++-4.1.2-46.el5

  • Errors

++ Running with 730 threads: execution is ok.

++Running with 751 threads: after 17 seconds of execution, the following error raises:

mmap: Cannot allocate memory

++ Running with 752+ threads:

Sometimes it raises the following error just after the execution:

rbx: vm/util/thread.hpp:115: void thread::Thread::run(): Assertion `pthread_create(&native_, &attrs, trampoline, (void*)this) == 0' failed.

Sometimes, after 10-15 seconds of execution, it raises:

Segmentation Fault
@dbussink
Rubinius member

You've hit two bugs at once here I think, Evan fixed an issue in the GC in commit defd53a and I've fixed the issue that it should not segfault but throw a ThreadError if it can't create more threads in commit 0bec6e5.

Could you test it again?

@evanphx
Rubinius member

No word, assuming fixed.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment