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

identify_create_stream_client' appears to have an infinite recursion, causing the stack to overflow and resulting in a core dump. #1445

Closed
shantengfei opened this issue Sep 15, 2019 · 1 comment
Assignees
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Milestone

Comments

@shantengfei
Copy link

shantengfei commented Sep 15, 2019

Phenomenon: In the SRS (Simple Real-time Streaming) system, when entering the stream_service_cycle to provide service, the client is first verified. When it is determined to be Identify_create_stream_client, it will enter the function to create a stream. However, when parsing the information sent by the client, if it is still about creating a stream, it will call Identify_create_stream_client again. If the client continuously sends requests to create a stream, it will recursively call Identify_create_stream_client, causing a loop and eventually causing a core dump.

Changes made: After receiving the message, the basic header, message header, and payload are parsed. Previously, when parsing the message header, a 31-bit timestamp was used in the timestamp section. According to the RTMP (Real-Time Messaging Protocol) protocol, the extended timestamp is an absolute timestamp when fmt=0, and it is a delta value when fmt=1 or 2. Referring to the ngx_rtmp_recv function in the ngx_rtmp_module, the original timestamp parsing logic was modified as follows: for fmt=0, the original absolute timestamp is maintained, and for fmt=1 or 2, the delta value is used. After the modification, the aforementioned core dump issue occurred. Currently, it is not certain whether modifying the timestamp caused the continuous occurrence of the create_stream problem. This is because the core dump may be caused by modifying the timestamp, or it may be due to abnormal behavior of the client, continuously sending requests to create a stream.

TRANS_BY_GPT3

@winlinvip winlinvip added the Bug It might be a bug. label Dec 11, 2019
@winlinvip winlinvip added this to the SRS 3.0 release milestone Dec 11, 2019
@winlinvip
Copy link
Member

winlinvip commented Dec 11, 2019

It has nothing to do with the timestamp and has already limited the maximum recursion to 3 times. Refer to: 4f29813

Unit test verification:

VOID TEST(ProtoStackTest, ServerRecursiveDepth)
{
    srs_error_t err;

    // For N*CreateStream and N>3, it should fail.
    if (true) {
        MockBufferIO io;
        SrsRtmpServer r(&io);

        if (true) {
            MockBufferIO tio;
            SrsProtocol p(&tio);

            for (int i = 0; i < 4; i++) {
                SrsCreateStreamPacket* call = new SrsCreateStreamPacket();
                HELPER_EXPECT_SUCCESS(p.send_and_free_packet(call, 0));
            }

            io.in_buffer.append(&tio.out_buffer);
        }

        string stream_name;
        SrsRtmpConnType tp;
        srs_utime_t duration = 0;
        HELPER_EXPECT_FAILED(r.identify_client(1, tp, stream_name, duration));
    }
}

TRANS_BY_GPT3

@winlinvip winlinvip self-assigned this Sep 6, 2021
@winlinvip winlinvip changed the title identify_create_stream_client出现无限递归导致栈爆掉出core现象 identify_create_stream_client' appears to have an infinite recursion, causing the stack to overflow and resulting in a core dump. Jul 29, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

2 participants