Manoj
Manoj

Reputation: 93

PThread Create Failed Linux

I have been working on a project where Mobile Application calls my java application and stores the data. I'm seeing this following error in logs in my virtual instance atleast once in 10 times. I'm sure that Its not an application error.

18 threadpool_pthread_impl.cc:51] Check failed: res == 0 (11 vs. 0) pthread_create failed

*** Check failure stack trace: ***

I checked my threads-max in kernel

cat /proc/sys/kernel/threads-max

thread-max value - >508172

and I can see the swap memory as 14GB and stack size is 8MB and max user processor is 4096

I'm trying to find a solution for quite some time and couldn't find it.

Upvotes: 1

Views: 1731

Answers (1)

Employed Russian
Employed Russian

Reputation: 213626

I'm sure that Its not an application error.

You are most likely mistaken about that. Common cause is not joining the threads after they exit, or creating new threads with no bound.

Error 11 is EAGAIN, which means that some limit is exhausted. From man pthread_create:

EAGAIN A system-imposed limit on the number of threads was encountered. There are a number of limits that may trigger this error: the RLIMIT_NPROC soft resource limit (set via setrlimit(2)), which limits the number of processes and threads for a real user ID, was reached; the kernel's system-wide limit on the number of processes and threads, /proc/sys/kernel/threads-max, was reached (see proc(5)); or the maximum number of PIDs, /proc/sys/kernel/pid_max, was reached (see proc(5)).

max user processor is 4096

You mean max user processes. That seems pretty low (note that this counts all threads in all processes created by current user). I'd start by setting it much higher.

Upvotes: 1

Related Questions