Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › C++ DLL Using MFC. Works in debug build. In release build, my objects get currupted.
New Posts  All Forums:Forum Nav:

C++ DLL Using MFC. Works in debug build. In release build, my objects get currupted.

post #1 of 4
Thread Starter 
First off, let me say that I am a bit of a n00b at C++, and don't know much about good coding practices.

So, I was going about my business writing my application in debug mode. I've been working on it 8 hours a day. It's been over a week since I tried to build release mode. When I tried to build for release, something goes crazy corrupts the memory.

Now, I have multiple threads going on. While I'm watching thread A lets say, thread B is waiting. Thread A finishes it's job, then when i come back to thread B the memory is all hosed up with garbage.



How do i tackle a problem like this? What is the best approach?

I have experience in the embedded world, and experience developing for the PC in the .NET world.....but this unmanaged C++ DLL thing is a entirely new can of worms for me.

In the embedded world, i can watch the stack and the heap. In Visual studios however, I don't believe I can do that. Are their any tools or plug-ins for visual studios?

I can show code if you want, but i do not know where to start.
Edited by crimsontears809739 - 10/4/12 at 12:39pm
Deus Ex Machina
(21 items)
 
   
CPUMotherboardGraphicsRAM
i5 2500K 4.8GHz @1.4V ASRock P67 Fatal1ty Professional Asus GTX 570 DCII 920 MHz @ 1.125V 8Gb G.Skill Ripjaws 
Hard DriveHard DriveHard DriveHard Drive
OCZ Vertex 3 Samsung Spinpoint F3 Western Digital Caviar SE16 WD2500KS SAMSUNG SpinPoint P Series SP2504C  
Hard DriveOptical DriveOptical DriveCooling
Western Digital Caviar Blue WD5000AAKS 12x Blu-ray Burner ASUS DRW-24B1ST DVD Burner Scythe Mugen II 
OSMonitorMonitorKeyboard
Windows 7 Samsung SyncMaster 23" (2nd monitor) Hewlett Packard HP f1703 17" Logitech G510 
PowerCaseMouseAudio
Corsair Professional HX750 Coolmaster HAF X Microsoft Wireless Laser Mouse 5000 120 Watt Sony Shelf System 
CPUMotherboardGraphicsRAM
i5 580M Dell 0R1203 NVIDIA Quadro FX 2800M Samsung 4Gb 
Hard DriveHard DriveOptical DriveOS
TOSHIBA MK3256GSYF  TOSHIBA MK3256GSYF  DVD-Rom HL-DT-ST DVD+-RW GU40N Windows 7 Professional 
Audio
Dell Computer 5 Series/3400 Series Chipset Fami... 
CPUMotherboardGraphicsGraphics
Athlon 64 X2 6400+  Asus M2N-E Nforce 500 SLi 8800GT  9800 GT 
RAMHard DriveOptical DriveOS
OCZ ReaperX WD LG lightscribe Multilayer DVD burner Windows 7 
PowerCase
Antec 500W Smartpower 2.0 Aspire X-Navigator 
  hide details  
Reply
Deus Ex Machina
(21 items)
 
   
CPUMotherboardGraphicsRAM
i5 2500K 4.8GHz @1.4V ASRock P67 Fatal1ty Professional Asus GTX 570 DCII 920 MHz @ 1.125V 8Gb G.Skill Ripjaws 
Hard DriveHard DriveHard DriveHard Drive
OCZ Vertex 3 Samsung Spinpoint F3 Western Digital Caviar SE16 WD2500KS SAMSUNG SpinPoint P Series SP2504C  
Hard DriveOptical DriveOptical DriveCooling
Western Digital Caviar Blue WD5000AAKS 12x Blu-ray Burner ASUS DRW-24B1ST DVD Burner Scythe Mugen II 
OSMonitorMonitorKeyboard
Windows 7 Samsung SyncMaster 23" (2nd monitor) Hewlett Packard HP f1703 17" Logitech G510 
PowerCaseMouseAudio
Corsair Professional HX750 Coolmaster HAF X Microsoft Wireless Laser Mouse 5000 120 Watt Sony Shelf System 
CPUMotherboardGraphicsRAM
i5 580M Dell 0R1203 NVIDIA Quadro FX 2800M Samsung 4Gb 
Hard DriveHard DriveOptical DriveOS
TOSHIBA MK3256GSYF  TOSHIBA MK3256GSYF  DVD-Rom HL-DT-ST DVD+-RW GU40N Windows 7 Professional 
Audio
Dell Computer 5 Series/3400 Series Chipset Fami... 
CPUMotherboardGraphicsGraphics
Athlon 64 X2 6400+  Asus M2N-E Nforce 500 SLi 8800GT  9800 GT 
RAMHard DriveOptical DriveOS
OCZ ReaperX WD LG lightscribe Multilayer DVD burner Windows 7 
PowerCase
Antec 500W Smartpower 2.0 Aspire X-Navigator 
  hide details  
Reply
post #2 of 4
In Visual Studio you can watch any memory location. If you want even PM me the whole source code and I'll run through it all.

Threading is difficult.
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
post #3 of 4
Thread Starter 
It's optimization that messed me up! I had "No whole program Optimization" set,...but apparently I also needed to turn off C++ Optimisation --> Disabled as well.

Now it's probably a bad coding practice behind all this, but I'll live with optimization off for now. :-/ I wasted 6 hours yesterday on this stupid problem. Moving forward now.

Thank you tompsonn for the offer. ^__^ I feel bad for answering my own questions.
Deus Ex Machina
(21 items)
 
   
CPUMotherboardGraphicsRAM
i5 2500K 4.8GHz @1.4V ASRock P67 Fatal1ty Professional Asus GTX 570 DCII 920 MHz @ 1.125V 8Gb G.Skill Ripjaws 
Hard DriveHard DriveHard DriveHard Drive
OCZ Vertex 3 Samsung Spinpoint F3 Western Digital Caviar SE16 WD2500KS SAMSUNG SpinPoint P Series SP2504C  
Hard DriveOptical DriveOptical DriveCooling
Western Digital Caviar Blue WD5000AAKS 12x Blu-ray Burner ASUS DRW-24B1ST DVD Burner Scythe Mugen II 
OSMonitorMonitorKeyboard
Windows 7 Samsung SyncMaster 23" (2nd monitor) Hewlett Packard HP f1703 17" Logitech G510 
PowerCaseMouseAudio
Corsair Professional HX750 Coolmaster HAF X Microsoft Wireless Laser Mouse 5000 120 Watt Sony Shelf System 
CPUMotherboardGraphicsRAM
i5 580M Dell 0R1203 NVIDIA Quadro FX 2800M Samsung 4Gb 
Hard DriveHard DriveOptical DriveOS
TOSHIBA MK3256GSYF  TOSHIBA MK3256GSYF  DVD-Rom HL-DT-ST DVD+-RW GU40N Windows 7 Professional 
Audio
Dell Computer 5 Series/3400 Series Chipset Fami... 
CPUMotherboardGraphicsGraphics
Athlon 64 X2 6400+  Asus M2N-E Nforce 500 SLi 8800GT  9800 GT 
RAMHard DriveOptical DriveOS
OCZ ReaperX WD LG lightscribe Multilayer DVD burner Windows 7 
PowerCase
Antec 500W Smartpower 2.0 Aspire X-Navigator 
  hide details  
Reply
Deus Ex Machina
(21 items)
 
   
CPUMotherboardGraphicsRAM
i5 2500K 4.8GHz @1.4V ASRock P67 Fatal1ty Professional Asus GTX 570 DCII 920 MHz @ 1.125V 8Gb G.Skill Ripjaws 
Hard DriveHard DriveHard DriveHard Drive
OCZ Vertex 3 Samsung Spinpoint F3 Western Digital Caviar SE16 WD2500KS SAMSUNG SpinPoint P Series SP2504C  
Hard DriveOptical DriveOptical DriveCooling
Western Digital Caviar Blue WD5000AAKS 12x Blu-ray Burner ASUS DRW-24B1ST DVD Burner Scythe Mugen II 
OSMonitorMonitorKeyboard
Windows 7 Samsung SyncMaster 23" (2nd monitor) Hewlett Packard HP f1703 17" Logitech G510 
PowerCaseMouseAudio
Corsair Professional HX750 Coolmaster HAF X Microsoft Wireless Laser Mouse 5000 120 Watt Sony Shelf System 
CPUMotherboardGraphicsRAM
i5 580M Dell 0R1203 NVIDIA Quadro FX 2800M Samsung 4Gb 
Hard DriveHard DriveOptical DriveOS
TOSHIBA MK3256GSYF  TOSHIBA MK3256GSYF  DVD-Rom HL-DT-ST DVD+-RW GU40N Windows 7 Professional 
Audio
Dell Computer 5 Series/3400 Series Chipset Fami... 
CPUMotherboardGraphicsGraphics
Athlon 64 X2 6400+  Asus M2N-E Nforce 500 SLi 8800GT  9800 GT 
RAMHard DriveOptical DriveOS
OCZ ReaperX WD LG lightscribe Multilayer DVD burner Windows 7 
PowerCase
Antec 500W Smartpower 2.0 Aspire X-Navigator 
  hide details  
Reply
post #4 of 4
Quote:
Originally Posted by crimsontears809739 View Post

It's optimization that messed me up! I had "No whole program Optimization" set,...but apparently I also needed to turn off C++ Optimisation --> Disabled as well.
Now it's probably a bad coding practice behind all this, but I'll live with optimization off for now. :-/ I wasted 6 hours yesterday on this stupid problem. Moving forward now.
Thank you tompsonn for the offer. ^__^ I feel bad for answering my own questions.

Eek. Yes you're right, bad programming can cause problems with compiler optimizations. I've never had to switch it off...
If you ever want to fix it properly let me know wink.gif
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
My System
(30 items)
 
"Zeus"
(13 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i5 2500K (4.5ghz @ 1.320v) Gigabyte Z68X-UD3R-B3 MSI R7970 Lightning Corsair 16GB (4x4GB) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Crucial M4 128GB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 7 Ultimate 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2212HM Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Microsoft IntelliMouse Optical  XTRAC Ripper XXL 
AudioAudioAudioAudio
Westone W3 IEMs RE-272 IEMs Shure SE-215 IEMs Schiit Bifrost DAC 
AudioAudio
Schiit Asgard 2 amp HiVi Swan M50W 2.1 
CPUMotherboardGraphicsRAM
Intel Core i7 950 GA-X58-UD3R Radeon HD 5450  24GB Corsair @ 1333mhz 
Hard DriveOSPowerCase
4x WD Cavair Red 1TB in RAID 0 Windows Server 2008 R2 x64 Corsair HX-520 LianLi LanCool 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › C++ DLL Using MFC. Works in debug build. In release build, my objects get currupted.