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

Multiple Invocations of cpr::MultiPerform Segfault #1047

Open
COM8 opened this issue Apr 28, 2024 · 0 comments
Open

Multiple Invocations of cpr::MultiPerform Segfault #1047

COM8 opened this issue Apr 28, 2024 · 0 comments
Labels

Comments

@COM8
Copy link
Member

COM8 commented Apr 28, 2024

Description

Invoking any cpr::MultiPerform request e.g. cpr::MultiPerform::Get(); multiple times on the same object leads to a crash (SegFault) during the second invocation.

This leads to cpr::MultiPerform to being reusable.

Example/How to Reproduce

Here is an example test case:

TEST(MultiperformGetTests, MultiperformSingleSessionMultiGetTest) {
    Url url{server->GetBaseUrl() + "/hello.html"};
    std::shared_ptr<Session> session = std::make_shared<Session>();
    session->SetUrl(url);
    MultiPerform multiperform;
    multiperform.AddSession(session);
    std::vector<Response> responses = multiperform.Get();

    EXPECT_EQ(responses.size(), 1);
    std::string expected_text{"Hello world!"};
    EXPECT_EQ(expected_text, responses.at(0).text);
    EXPECT_EQ(url, responses.at(0).url);
    EXPECT_EQ(std::string{"text/html"}, responses.at(0).header["content-type"]);
    EXPECT_EQ(200, responses.at(0).status_code);
    EXPECT_EQ(ErrorCode::OK, responses.at(0).error.code);

    // Invoke for the second time
    responses = multiperform.Get(); // Fails here
    EXPECT_EQ(responses.size(), 1);
    EXPECT_EQ(expected_text, responses.at(0).text);
    EXPECT_EQ(url, responses.at(0).url);
    EXPECT_EQ(std::string{"text/html"}, responses.at(0).header["content-type"]);
    EXPECT_EQ(200, responses.at(0).status_code);
    EXPECT_EQ(ErrorCode::OK, responses.at(0).error.code);
}

Possible Fix

No response

Where did you get it from?

GitHub (branch e.g. master)

Additional Context/Your Environment

  • OS: Fedora 39
  • Version: Master as of 28.04.2024 - bed704f
@COM8 COM8 added the Bug 🐛 label Apr 28, 2024
@COM8 COM8 changed the title Multiple Invocations of Multiple Invocations of cpr::MultiPerform Segfault May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant