none
My project is failing at release mode, but working properly in debug mode. RRS feed

  • Question

  • Hi, 

    I am calling my .cpp project from .cs project with the help of Dll, it is working properly in debug mode , but when i tried at release mode. it is crashing at below line:

    void Fun(std::istream &is, bool bin, const char *token) {
      int pos_at_start = is.tellg();
      if (!binary) is >> std::ws;  // consume whitespace.
      std::string str;
      is >> str;
      is.get();

    if (is.fail()) {
        LOG << "Failed to read token [started at file position "     //returning from here 
                  << pos_at_start << "], expected " << token;
      }

     ============

    Please help.



    Friday, August 23, 2019 12:16 PM

All replies

  • Hmm, very similar problem as was discussed at My program is crashing at get line in release mode, it is working properly in debug mode, i am using VS2017. Please help.

    Also using  C# code and a helper DLL. Also no details about helper DLL provided.

    Show us the C# code you use.  Also show us the relevant code in the helper DLL

    Friday, August 23, 2019 2:33 PM
  • Hi KabeerSdiq48,

    Sorry for delay in reply.

    According to your description, please check if the file is locked, which is like below image:

    And if it persists, could you please share the crash details uisng below code? 

    cerr << "Error: " << strerror(errno);

    Please refer more about this: https://stackoverflow.com/a/17338934

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Monday, August 26, 2019 3:46 AM
  • Output of : std::cerr << "Error: " << std::strerror(errno); 

    Error: No errorERROR

    and file was not locked.


    Monday, August 26, 2019 11:11 AM
  • void Fun(std::istream &is, bool bin, const char *token) {
      int pos_at_start = is.tellg();
      if (!binary) is >> std::ws;  // consume whitespace.
      std::string str;
      is >> str;
      is.get();

    if (is.fail()) {

    std::cerr << "Error: " << std::strerror(errno);      

    LOG << "Failed to read token [started at file position "     //  returning from here 
                  << pos_at_start << "], expected " << token;
      }


    Monday, August 26, 2019 11:38 AM
  • Hi KabeerSadiq48,

    Thank you for feedback.

    Please try to debug your project under release mode:

    #1 open project properties

    #2 select "General", set "Debug information format" to "Program Database (/Zi)"


    #3 select "Optimization", set "Optimization" to "Disabled (/Od)"

    #4 select "Debugging",set "Generate Debug Info" to "Generate Debug Information (/DEBUG)"

    If it could work for you, please double-check your code, such as clean up some false assumptions, or hover the pointer, which could be hidden trouble for your future project. And you can also limit the cause of the error to a certain range via optimization option.

    Any feedback will be expected.

    Best Regards,

    Dylan




    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Tuesday, August 27, 2019 7:42 AM
  • Hi @Dylan,

    Thanks for response,

    But it didn't work.  

    Tuesday, August 27, 2019 9:31 AM