crash in QJsonDocument::fromJson
-
I have a file to store encrypted json binary data.
Here is the code:
// compressedData is read from file, then decrypted QByteArray uncompressedData = qUncompress(compressedData); if (uncompressedData.size() == 0) { qWarning() << "[att_store] failed to uncompress, uuid:" << uuid; return ErrorCode::DB_ATT_PARSE_ERROR; } // parse json QJsonParseError err; QJsonDocument doc = QJsonDocument::fromJson(uncompressedData, &err); // <--- crash here if (err.error != QJsonParseError::NoError) { qWarning() << "[att_store] failed to parse json, err:" << static_cast<int>(err.error) << "size:" << uncompressedData.size() << "uuid:" << uuid; return ErrorCode::DB_ATT_PARSE_ERROR; }
When reading from file, sometimes, I get crash like this:
STACK_TEXT: 000000ea`b39fa760 00007ffc`f6b7486d : 00000000`00000000 00007ffd`032a83d0 000001ee`eafe7633 001c35d7`00000000 : KERNELBASE!RaiseException+0x68 000000ea`b39fa840 000001ee`e99c1a0f : 000001ee`e9700000 000000ea`b39fa950 000000ea`b39fa9d0 00007ffc`ff7ea828 : VCRUNTIME140!CxxThrowException+0xad 000000ea`b39fa8b0 000001ee`e993dcf5 : 000000ea`b39fa950 000001ee`e973df78 00000000`001c35db 000000ea`b39faa58 : Qt5Core!__scrt_throw_std_bad_alloc+0x1f 000000ea`b39fa900 000001ee`e99362e8 : ffffffff`fffffffe 000000ea`b39fa9d0 000001ee`ea802758 00000000`00000000 : Qt5Core!QJsonPrivate::Parser::parse+0x45 000000ea`b39fa930 00007ff7`766c4d8c : 00000000`001c35db 000000ea`003fc14b 000001ee`ea802758 000001ee`eaff2040 : Qt5Core!QJsonDocument::fromJson+0x38 000000ea`b39fa990 00007ff7`7667ea82 : 000001ee`e9c92180 000000ea`b39fab18 000001ee`ea802758 000001ee`eaff2040 : CortexSync!Cortex::Storage::TrainingAttributesStore::get+0x33c
It happens on Windows.
Can anyone know why? The file still can be read, decrypted then decompressed and parsed to json normally several times before this crash happens. -
@VRonin Thanks. I have another crash (seems the same root cause), when reading from that file:
STACK_TEXT: 00000046`b70fac20 00007ff8`3b07486d : 000001f4`bc5af770 00007ff8`4476284a 00000000`00000008 00000000`00000008 : KERNELBASE!RaiseException+0x68 00000046`b70fad00 00007fff`fb141a0f : 00007fff`fae80000 00000046`b70fae60 00000000`0034ec46 00007fff`fafd6cdb : VCRUNTIME140!_CxxThrowException+0xad 00000046`b70fad70 00007fff`faebf74a : 00000046`b70fae60 000001f4`bd3cfb00 00000000`00000000 000001f4`00000000 : Qt5Core!__scrt_throw_std_bad_alloc+0x1f 00000046`b70fadc0 00007fff`fafa7bac : 000001f4`bd3cfb00 00000000`0034ec46 00000046`b70ff2f0 000001f4`bd32b0f8 : Qt5Core!QByteArray::resize+0xca 00000046`b70fadf0 00007ff7`74b44c7d : 00007fff`fb412180 00000046`b70fae88 000001f4`bd32b0f8 000001f4`bd4b2a20 : Qt5Core!QIODevice::readAll+0x1ac 00000046`b70fae60 00007ff7`74afea82 : 000001f4`00000008 00000046`b70fafe8 000001f4`bd32b0f8 00000000`00000001 : CortexSync!Cortex::Storage::TrainingAttributesStore::get+0x22d
Can you say more about this?
-
@thamht4190 said in crash in QJsonDocument::fromJson:
__scrt_throw_std_bad_alloc
I don't think it's anything to do with Qt:
-
@thamht4190 said in crash in QJsonDocument::fromJson:
Can you say more about this?
Like @VRonin already said: "Either you have a memory leak somewhere or you are just storing too much data in RAM"
Monitor your app's memory usage while it runs.
-
Thanks! I understand the problem now. I'll monitor my application memory usage.
-
I monitored my application's memory usage. Unfortunately I don't see any problems. My application's memory usage is <10Mb at minimum usage and < 100Mb at maximum usage and there is no memory leak.
Note that the crashes I received are reported automatically from my customers' machine. I've never seen this crash before among a lot of machines, only the machine of this customer.
Here is some info from this machine:Windows 10 Version 17134 MP (4 procs) Free x64 Product: WinNt, suite: SingleUserTS Personal 17134.1.amd64fre.rs4_release.180410-1804
I know that it's NOT Qt problem. However, can you help give me some any suggestions/ideas to investigate more?
-
How big is your uncompressed data?
-
How big is your uncompressed data?
@Christian-Ehrlicher we have more than 1 files. As I checked on this machine (from logs), there are 2 files, about 7 - 10Mb per each file.
-
@thamht4190 is it possible, that the JSON is corrupted/invalid so that some recursion within Qt's classes happens?
-
The only way I see is to reduce the json until it does not crash anymore or use a debug build of Qt to see exactly where and why the parser crashes.
-
Thanks. I'll try to contact this customer to see if I can have his data to confirm the possibility that his data is corrupted/invalid.