I get a Seg Fault on GET request. Version 1.9.0
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
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}.
And a complete stack trace please 😄 .
And a complete stack trace please smile .
The precise point of the crash :

cpr::Session ~Session

And my call :

Thanks for your time.
Edit : I've tested the api call with Insomnia, and It's work just fine.
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;
}
response_string_reserve_size_ also has a rather "broken" value.
So with util.cpp modified as this :

I get the same result.

Thanks !
OK, then I do not know any further. Could you please provide a minimal example, so I can debug this?
Ok, I'm working on it. Thanks for your time.
Any updates on this issue?
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: @.***>