Author Topic: runtime problems  (Read 5060 times)

0 Members and 1 Guest are viewing this topic.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
runtime problems
« on: June 27, 2013 »
hey again guys,

i've developed some weird issues. i went too add a camera system too my project which all went smooth its a look at camera. it works as expected using glm.. but only inside the vs 10 ide using visual studios play button. the minute i shut the ide down and double click my produced exe the camera is all screwed up it rotates in strange directions and starts in a different position from specified. its strange the only thing i've found is that when statically linking my glew lib into the exe in debug mode i got a few linker errors along the lines of.

1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>C:\Users\ninogenio\Desktop\apophis\Debug\apophis.exe : fatal error LNK1169: one or more multiply defined symbols found

which i belive comes from the fact that glew has been built with different run time libs.

just wondering if any of you guys have ever had similar issues. and why an exe thats run from inside the ide would behave differently too exiting the ide and running manually..

Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: runtime problems
« Reply #1 on: June 27, 2013 »
just read that uninitialized variables can cause weird things too happen, between debug and release mode in vs the compiler masks them out in release but not debug.. could a similar thing happen between running an exe in the ide and running it outside?!..

i'm just scanning my code for any unset vars i think there might in fact be a few cases in my camera class where a few of the vars will be filled with junk from the heap.

edit.... it was indeed uninitialized variables. how strange.

in one small instance i was putting a call too rotate one of my 3dobjects before setting the internal rotation varibles. and this was enough too send everything crazy. i suspect i was getting a bit of gimbal lock when trying too multply the veiw matrix against this objects matrix. but it still begs the question why would vs cover this up while running my code from the ide. but not from the exe??.. im glad i fixed it but am perplexed at how it came about in the first place.
« Last Edit: June 27, 2013 by ninogenio »
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: runtime problems
« Reply #2 on: June 30, 2013 »
Because in debug mode the CRT fills memory with 0xCB bytes where it is not required to zero it out or leave it alone.
Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: runtime problems
« Reply #3 on: July 01, 2013 »
thanks jim,

i take it a similar sort of thing happens between running an exe inside the ide and running outside? that was the thing that got me a little confused.

cheers.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: runtime problems
« Reply #4 on: July 07, 2013 »
The executable's memory location is likely different and/or memory is filled with different left-overs under the debugger/IDE and so the uninitialised variable is filled with different random crap causing different behaviour.

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: runtime problems
« Reply #5 on: July 07, 2013 »
cheers jim,

yup that makes perfect sense. after this little bug i am being extra careful too zero all memory upon allocation so this sort of thing doesn't come around again, it can be a real pain too track these sorts of bugs down.
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: runtime problems
« Reply #6 on: July 08, 2013 »
In Visual Studio the debugger stops when you access an uninitialized variable, so these things are "usually" easy to find.
It's still good habbit to initialize your stuff properly, especially for the few "unusual" cases...
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: runtime problems
« Reply #7 on: July 08, 2013 »
yeah this was indeed one if those special, "there is a problem some where, but everything is perfectly fine" cases.

but really, i hold my hands up too lazy coding on my end. im just being extra methodical now so this should never be a problem again.
Challenge Trophies Won: