Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7714279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:05:17+00:00 2026-06-01T02:05:17+00:00

For some odd reason, my application likes to break on me when I switch

  • 0

For some odd reason, my application likes to break on me when I switch to release and run it outside of my debugger. Here’s what works for me, and here’s what doesn’t

(Qt Creator is the IDE)

  • Debugging with debug configuration – ok
  • Running with debug configuration – ok
  • Debugging with release configuration – ok
  • Running with release configuration – application crash

My UI is one project, and the core for some stuff as a separate dependency. On Windows (compiling with MSVCC), I hit a menu button, which eventually calls down to a function. In that function, the app breaks on adding a new element to a vector. e.g:

str *x = new str();
str *y = new str();
/* ...set some of x & y's members... */
vector.push_back(x); // works fine
vector.push_back(y); // causes crash

If I comment out the line vector.push_back(y);, the app continues no problem until the app leaves the event scope (i.e. the end of OnMenuButtonClick). On OS X, it’s similar to the issue of adding an element to a vector, except I have:

std::vector<foo *> SomeFunction()
{
   std::vector<foo *> returningVector;
   /* do stuff */
   std::vector<foo *> goo = GetFooObjects();
   for (int i = 0; i < goo.size(); i++)
   {
       returningVector.push_back(goo[i]); // breaks here
   }
}

So what are some causes of this strange behavior without a debugger attached and not under debug configuration? I’ve checked to make sure all of my variables are initialized, so I’m stumped. If you want to view the code above, the first part can be located here, and the second part here. Please forgive anything you see as “bad”, and if you have suggestions that you just can’t contain, then please do message me on GitHub.

Edit:

I looked more into it, and found out exactly what’s causing the problem, but don’t know how to fix it. This is the function where my app crashes (on OS X):

vector<Drive *> Drive::GetFATXDrives( bool HardDisks )
{
    vector<Drive *> Return;
    if (HardDisks)
    {
        vector<DISK_DRIVE_INFORMATION> Disks = GetPhysicalDisks();
        for (int i = 0; i < (int)Disks.size(); i++)
        {
            DISK_DRIVE_INFORMATION ddi = Disks.at(i);
            // First, try reading the disk way
            Streams::xDeviceStream* DS = NULL;
            try
            {
                char path[0x200] = {0};
                wcstombs(path, ddi.Path, wcslen(ddi.Path));
                DS = new Streams::xDeviceStream(ddi.Path);
            }
            catch (xException& e)
            {
                continue;
            }

            if (DS == NULL || DS->Length() == 0 || DS->Length() < HddOffsets::Data)
            {
                // Disk is not of valid length
                continue;
            }
            DS->SetPosition(HddOffsets::Data);

            // Read the FATX partition magic
            int Magic = DS->ReadInt32();
            // Close the stream
            DS->Close();

            // Compare the magic we read to the *actual* FATX magic
            if (Magic == FatxMagic)
            {
                Drive *d = new Drive(Disks.at(i).Path, Disks.at(i).FriendlyName, false);
                Return.push_back(d);
            }
        }
    }

    vector<Drive *> LogicalDisks = GetLogicalPartitions();
    for (int i = 0; i < (int)LogicalDisks.size(); i++)
    {
        Return.push_back(LogicalDisks.at(i));
    }

    return Return;
}

If I change if (HardDisks) to if (HardDisks = false), the app works just fine. So, I looked into that scope and discovered that after vector<DISK_DRIVE_INFORMATION> Disks = GetPhysicalDisks();, the heap gets corrupt or something like that. I noticed this because in the debugger, after that function is called, my HardDisks bool changes to “false”, which wasn’t what it was before.

Here is GetPhysicalDisks:

vector<Drive::DISK_DRIVE_INFORMATION> Drive::GetPhysicalDisks( void )
{
    // RIGHT AFTER this vector is initialized, everything goes to hell
    vector<Drive::DISK_DRIVE_INFORMATION> ReturnVector;

DIR *dir;
dirent *ent;
dir = opendir("/dev/");
if (dir != NULL)
{
    // Read the shit
    while ((ent = readdir(dir)) != NULL)
    {
        // Check the directory name, and if it starts with "disk" then keep it!
        QRegExp exp("disk*");
        exp.setPatternSyntax(QRegExp::Wildcard);
        exp.setCaseSensitivity(Qt::CaseInsensitive);
        if (exp.exactMatch(ent->d_name))
        {
            DISK_DRIVE_INFORMATION curdir;
            memset(curdir.FriendlyName, 0, sizeof(curdir.FriendlyName));
            memset(curdir.Path, 0, sizeof(curdir.Path));

            char diskPath[0x50] = {0};
            sprintf(diskPath, "/dev/r%s", ent->d_name);

            mbstowcs(curdir.Path, diskPath, strlen(diskPath));

            int device;
            if ((device = open(diskPath, O_RDONLY)) > 0)
            {
#ifdef __linux
                hd_driveid hd;
                if (!ioctl(device, HDIO_GET_IDENTITY, &hd))
                {
                    swprintf(curdir.FriendlyName, strlen(hd) * 2, L"%hs", hd.model);
                }
#elif defined __APPLE__
                mbstowcs(curdir.FriendlyName, ent->d_name, strlen(ent->d_name));
#endif
                ReturnVector.push_back(curdir);
            }
        }
    }
}
    return ReturnVector;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:05:19+00:00Added an answer on June 1, 2026 at 2:05 am

    While this isn’t a real answer as to what happened, I did find a way to fix the problem. Looking at my edit above, I edited my Drive::GetFATXDrives function like so:

    vector<Drive *> Drive::GetFATXDrives( bool HardDisks )
    {
        // Initialize Disks vector up here
        vector<DISK_DRIVE_INFORMATION> Disks;
        // Call the function to get the hard disks
        if (HardDisks)
            Drive::GetPhysicalDisks(Disks);
    
        vector<Drive *> ReturnVector;
        if (HardDisks)
        {
            Streams::xDeviceStream* DS = NULL;
            for (int i = 0; i < (int)Disks.size(); i++)
            {
                /* ... */
            }
            if (DS)
            {
                DS->Close();
                delete DS;
            }
        }
    
        vector<Drive *> LogicalDisks = GetLogicalPartitions();
        for (int i = 0; i < LogicalDisks.size(); i++)
        {
            ReturnVector.push_back(LogicalDisks[i]);
        }
    
        return ReturnVector;
    }
    

    And my Drive::GetPhysicalDisks function now takes a vector<DISK_DRIVE_INFORMATION> reference instead of returning one. Seemed to make my program work just fine after that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some odd reason Internet Explorer won't run my queries properly. I designed this
I have this asp.NET web site that for some odd reason doesn't want to
For some odd reason the part where objects are shown and hidden in my
For some odd reason, my project is generating two icons, same name, launches the
For some odd reason, the apc file upload status gives me the file size
for some odd reason the text area I have in my site won't accept
So I am making an iPhone program and for some odd reason the title
I actually have two questions, both are probably simple, but for some odd reason
I'm receiving this error for some odd reason: Fatal error: Class 'crud_model' not found
For some odd reason, the default module and action are being used when a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.