cpr icon indicating copy to clipboard operation
cpr copied to clipboard

I get a Seg Fault on GET request. Version 1.9.0

Open Reivax47 opened this issue 3 years ago • 9 comments

Hi !

I've just moved from 1.7.0 to 1.9.0 this morning and I get a seg fault on my first GET request. This line in session.h make it crash: ~Session() = default;

Up in the pile, in cpr::Get, I get this : str_ = <error reading variable: Cannot create a lazy string with address 0x0, and a non-zero length.><error reading variable: Cannot create a lazy string with address 0x0, and a non-zero length.>

I have no idea why I get this. I didn't change the way I'm calling the GET request :

cpr::Url url = cpr::Url{this->adresse_root + requete}; cpr::Response monRetour = cpr::Get( url );

Thanks !

Your Environment

  • Version used: 1.9.0
  • Where did you get it from (e.g. conan, vcpkg, master, ...): CMAKE
  • Operating System and version: Debian 10

Reivax47 avatar Jul 26 '22 11:07 Reivax47

Thanks for taking the time to report this! Could you please provide a minimal example, since I currently can not reproduce this issue on Debian 10/Fedora 36 and Ubuntu {20.04, 22.04}.

COM8 avatar Jul 26 '22 12:07 COM8

And a complete stack trace please 😄 .

COM8 avatar Jul 26 '22 12:07 COM8

And a complete stack trace please smile .

The precise point of the crash : image

cpr::Session ~Session image

And my call : image

Thanks for your time.

Edit : I've tested the api call with Insomnia, and It's work just fine.

Reivax47 avatar Jul 26 '22 12:07 Reivax47

Since you are consuming cpr via CMake, could you please try the following patch. Replace writeFunction(...) inside cpr/util.cpp with the following patched version:

size_t writeFunction(char* ptr, size_t size, size_t nmemb, std::string* data) {
    size *= nmemb;
    if (ptr && size > 0) {
        data->append(ptr, size);
    }
    return size;
}

COM8 avatar Jul 26 '22 12:07 COM8

response_string_reserve_size_ also has a rather "broken" value.

COM8 avatar Jul 26 '22 12:07 COM8

So with util.cpp modified as this :
image

I get the same result. image

image Thanks !

Reivax47 avatar Jul 26 '22 12:07 Reivax47

OK, then I do not know any further. Could you please provide a minimal example, so I can debug this?

COM8 avatar Jul 26 '22 12:07 COM8

Ok, I'm working on it. Thanks for your time.

Reivax47 avatar Jul 26 '22 12:07 Reivax47

Any updates on this issue?

COM8 avatar Aug 11 '22 07:08 COM8

Hi Fabian,

Sorry to be late.

Yes and all was on me. I'm working on a remote device. On this device, CPR's update was not successful. I did update again and since then everything is fine.

Sorry again to not updated you and false report. Xavier.

Le jeu. 11 août 2022 à 09:18, Fabian Sauter @.***> a écrit :

Any updates on this issue?

— Reply to this email directly, view it on GitHub https://github.com/libcpr/cpr/issues/797#issuecomment-1211633624, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALKT5RBR2JSYTG6D2WOKNTTVYSSN7ANCNFSM54VVAWSQ . You are receiving this because you authored the thread.Message ID: @.***>

Reivax47 avatar Aug 13 '22 11:08 Reivax47