Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. crash in QJsonDocument::fromJson

crash in QJsonDocument::fromJson

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 5 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #2

    Looks like you are running out of memory. Either you have a memory leak somewhere or you are just storing too much data in RAM

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    T 1 Reply Last reply
    3
    • VRoninV VRonin

      Looks like you are running out of memory. Either you have a memory leak somewhere or you are just storing too much data in RAM

      T Offline
      T Offline
      thamht4190
      wrote on last edited by
      #3

      @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?

      VRoninV JKSHJ 2 Replies Last reply
      0
      • T thamht4190

        @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?

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #4

        @thamht4190 said in crash in QJsonDocument::fromJson:

        __scrt_throw_std_bad_alloc

        I don't think it's anything to do with Qt:

        • http://www.cplusplus.com/doc/tutorial/dynamic/
        • http://www.cplusplus.com/reference/new/bad_alloc/

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2
        • T thamht4190

          @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?

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #5

          @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.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          2
          • T thamht4190

            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.

            T Offline
            T Offline
            thamht4190
            wrote on last edited by
            #6

            Thanks! I understand the problem now. I'll monitor my application memory usage.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              thamht4190
              wrote on last edited by
              #7

              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?

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #8

                How big is your uncompressed data?

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                T 1 Reply Last reply
                1
                • Christian EhrlicherC Christian Ehrlicher

                  How big is your uncompressed data?

                  T Offline
                  T Offline
                  thamht4190
                  wrote on last edited by
                  #9

                  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.

                  aha_1980A 1 Reply Last reply
                  0
                  • T thamht4190

                    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.

                    aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @thamht4190 is it possible, that the JSON is corrupted/invalid so that some recursion within Qt's classes happens?

                    Qt has to stay free or it will die.

                    1 Reply Last reply
                    1
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      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.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      T 1 Reply Last reply
                      1
                      • Christian EhrlicherC Christian Ehrlicher

                        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.

                        T Offline
                        T Offline
                        thamht4190
                        wrote on last edited by
                        #12

                        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.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved