-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Too many coroutines caused memory allocation failure, terminate called after throwing an instance of 'std::bad_alloc'. #509
Comments
I also encountered version 2.0a2.
|
Please provide the configuration, logs, version, and steps to reproduce. Thank you~
|
My configuration is very simple, it consists of the default configuration files origin.conf and edge.conf. I changed the "origin" in edge.conf to my own server domain name. There is one origin and two edges. There are about 5 push streams and 50 pull streams. Both origin and edge have experienced downtime. The log for the edge is the same as the one mentioned above, and the log for the origin is as follows:
If needed, I can provide the core dump files.
|
Please send me the core and its corresponding SRS. You can also put it on a file sharing platform. Is it CentOS?
|
centos 7 64bit, related files can be found at http://pan.baidu.com/s/1pJGLnyN
|
Hmm, I'll find time to take a look.
|
Visible that the edge object is not damaged.
It is evident that the object has already been released, so using it again will definitely cause problems.
|
Stack.
|
Explanation: C0C1 has been completed, but S0S1S2 has not been received yet. This is an impossible execution path.
Explanation: When
|
Observing hs_bytes again: '
Among them, c0 should be 0x03, but it is actually 0xc8. '
|
Looking at the stack:
At this point, the observed hs_bytes are different from before, indicating a problem within the complex_hs.handshake_with_server. In the f1 section, c0c1 is a heap pointer, and the data starts with 03 without any corruption.
|
From the data of io, it can be seen that 3073 bytes (s0s1s2) were received and 1537 bytes (c0c1) were sent. There may have been a problem while processing s0s1s2.
|
This may be a problem caused by allocating objects on the stack. Change it to allocate on the heap.
|
https://stackoverflow.com/a/2504601
|
This article analyzes that bad_alloc is not always Out of Memory (OOM): http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1404r1.html Wrote an example, as follows:
Execution will crash.
Looking at the stack is not about allocating the majority, but about allocating the minority.
|
Added a gdb script, analyzed the number of coroutines in the core. Download the code srs.py first:
By default, ST uses mmap to allocate the stack space for coroutines. Therefore, if the number exceeds a certain limit, it will fail. You can check this limit using the following:
Then compile this code huge-threads.cpp and execute it.
Usually, it will hang around 30,000 coroutines here.
There are two solutions for this.
|
srs automatically exits when pulling the stream.
srs: src/app/srs_app_edge.cpp:766: virtual int SrsPlayEdge::on_ingest_play(): Assertion `state == SrsEdgeStatePlay' failed.
TRANS_BY_GPT3
The text was updated successfully, but these errors were encountered: