Closed JaredTherriault closed 1 year ago
No offense, but this seems like a work around for a problem in your code/compiler/stl. If I understood it correctly it boils down to:
std::string str3 = str1 + str2;
vs
std::string str3;
str3.reserve(str1.size() + str2.size());
str3.append(str2);
str3.append(str2);
which according to the standard should behave exactly the same. The later might be slightly more efficient as it prevents a realloc of the buffer, but that shouldn't cause crashes. I feel like theres some sort of race condition or something like that, thats now hidden because the resize causes the timing to shift slightly enough to not cause issues anymore.
Can you provide more details on where it crashes (e.g. a stack trace) ?
OpenSSL (and by extend jwt-cpp) is not threadsafe by default on most platforms and jwt-cpp makes no attempt in being it either, so if you reuse the same instance make sure not to do so from two threads at the same time.
@JaredTherriault Any update ?
I'll close this for now, if you have more information feel free to reopen
iOS crashes when calling sign twice in the same instance - this fix reserves the string memory ahead of time to prevent this.