Results 1 to 6 of 6

Thread: error: exited with code -1073740940 ask for help

  1. #1
    Join Date
    Feb 2020
    Posts
    4
    Qt products
    Qt5
    Platforms
    Windows

    Question error: exited with code -1073740940 ask for help

    Hi guys:

    I was stucked in a problem, the program can be built and run for a about 19 minutes, and then exited with code -1073740940.
    I don't know where can find the code means ?
    Develop environment : Qt 5.14.0 / Windows 10

    After checked my code and did a lot of test , I found that when I disable some code sections, it would run for a long time.
    The function was reading a block of dem data from memory, and it runs a about 60 times per second.

    Qt Code:
    1. short int* DemPreLoad::LoadDemData_Area()
    2. {
    3. short int* crop = (short int*)malloc(sizeof(short int) * _Terrian_Range * _Terrian_Range*4); // _Terrian_Range is const for 100
    4. Location location = getLocation(); // According to longtitude & latitude caculate which row & col the right data in the dem data map
    5. Location beginlocation;
    6. int beginIndex;
    7.  
    8. beginlocation.col = location.col - _Terrian_Range;
    9. beginlocation.row = location.row - _Terrian_Range;
    10. beginIndex = (int)(beginlocation.col + beginlocation.row * 43200);
    11.  
    12. for (int rows = 0; rows < _Terrian_Range * 2; rows++)
    13. {
    14. for (int cols = 0; cols < _Terrian_Range * 2; cols++)
    15. {
    16. crop[cols + rows * _Terrian_Range*2] = _DataNow[beginIndex + cols];
    17. if (demlow>_DataNow[beginIndex + cols]) demlow=_DataNow[beginIndex + cols];
    18. if (demhigh<_DataNow[beginIndex + cols]) demhigh=_DataNow[beginIndex + cols];
    19. }
    20. beginIndex += 43200;
    21. }
    22.  
    23. return crop;
    24. }
    To copy to clipboard, switch view to plain text mode 
    My questions are :
    1? Where could I find the code means.
    2? How could fix the problem(s).

    Thanks a lot.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: exited with code -1073740940 ask for help

    1. In line 3 You are allocating memory. You don't test if this was succesfull.
    2. Wherever you free that memory ?

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: error: exited with code -1073740940 ask for help

    If you modify your API a little bit, you could avoid this memory leak:

    Qt Code:
    1. void DemPreLoad::LoadDemData_Area( std::vector< short int > & crop )
    2. {
    3. crop.resize( _Terrian_Range * _Terrian_Range * 4, 0 );
    4. // ...
    5. }
    To copy to clipboard, switch view to plain text mode 

    or

    Qt Code:
    1. std::vector< short int > DemPreLoad::LoadDemData_Area( )
    2. {
    3. std::vector< short int > crop( _Terrian_Range * _Terrian_Range * 4, 0 );
    4. // ...
    5. return crop;
    6. }
    To copy to clipboard, switch view to plain text mode 

    And of course you would have to modify your calling code to use a vector instead of a pointer to an array, but since vector overloads operator[] you can access the members of the vector using crop[ i ] in exactly the same way as if you had "crop" defined as an int * pointer and used crop[ i ]. If you actually need to access the vector as a pointer to an array, then &(crop[0]) returns that pointer.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    Feb 2020
    Posts
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: error: exited with code -1073740940 ask for help

    I've rewrote the code like:
    Qt Code:
    1. std::vector<short int> DemPreLoad::LoadDemData_Area()
    2. {
    3. std::vector<short int> crop( _Terrian_Range * _Terrian_Range * 4, 0 );
    4. Location location = getLocation();
    5. Location beginlocation;
    6. int beginIndex;
    7. beginlocation.col = location.col - _Terrian_Range;
    8. beginlocation.row = location.row - _Terrian_Range;
    9. beginIndex = (int)(beginlocation.col + beginlocation.row * 43200);
    10.  
    11. for (int rows = 0; rows < _Terrian_Range * 2; rows++)
    12. {
    13. for (int cols = 0; cols < _Terrian_Range * 2; cols++)
    14. {
    15. crop[cols + rows * _Terrian_Range*2] = _DataNow[beginIndex + cols];
    16. if (demlow>_DataNow[beginIndex + cols]) demlow=_DataNow[beginIndex + cols];
    17. if (demhigh<_DataNow[beginIndex + cols]) demhigh=_DataNow[beginIndex + cols];
    18. }
    19. beginIndex += 43200;
    20. }
    21. //QDebug("%d\n",crop[0]);
    22. // putTestDataToFile(&(crop[0]));
    23. return crop;
    24. }
    To copy to clipboard, switch view to plain text mode 
    But it still get the error: exited with code -1073740940 after running about 30 minutes.

  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: exited with code -1073740940 ask for help

    -1073740940 it is 0xC0000374 in HEX. Ask Google what this is.

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: error: exited with code -1073740940 ask for help

    int beginIndex;
    beginlocation.col = location.col - _Terrian_Range;
    beginlocation.row = location.row - _Terrian_Range;
    beginIndex = (int)(beginlocation.col + beginlocation.row * 43200);

    // ...

    beginIndex += 43200;
    And when you have figured out what Google is telling you, maybe this code might have something to do with it. For one "magic numbers" (like 43200) are always suspect. Is this number some type of a constant for -all- DEM files? For another, when you are computing "beginLocation" you are -subtracting- "_Terrain_Range", which also seems suspicious.

    There might be good (and valid) reasons for this, but any time I see code like this I think, "there's an access error that's going end up corrupting memory".

    If you are accessing data using C-style pointers and pointer arithmetic, then the code doesn't care if the pointer is inside an array or data structure or not. It doesn't do any bounds checking. So if you aren't computing the pointer locations correctly, your code could be reading from (or worse) writing to any old random place in memory.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. error: exited with code -1073740940 ask for help
    By longkimari in forum Qt Programming
    Replies: 0
    Last Post: 26th February 2020, 03:07
  2. error: exited with code -1073740940 ask for help
    By longkimari in forum Qt Programming
    Replies: 0
    Last Post: 26th February 2020, 02:58
  3. exited with code -1073741511 error in runnig application from Qt-creator
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 4
    Last Post: 15th March 2012, 12:59
  4. Running example project with mingw gives "... exited with code -1073741792" error
    By sibercekirge in forum Installation and Deployment
    Replies: 8
    Last Post: 31st May 2011, 18:33
  5. exited with code -1073741819 error
    By arpspatel in forum Qt Programming
    Replies: 8
    Last Post: 2nd March 2010, 10:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.