Heres a hard one: ostream include / msvcp90d.dll not working

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2009
Posts: 6
Reputation: mOoEyThEcOw is an unknown quantity at this point 
Solved Threads: 0
mOoEyThEcOw mOoEyThEcOw is offline Offline
Newbie Poster

Heres a hard one: ostream include / msvcp90d.dll not working

 
1
  #1
Jun 26th, 2009
So I was coding along working on another dll, I recompiled a dll containing the following code and suddenly my program was crashing, when i clicked the show info link on the 'send this report to Microsoft' dialog box, it said the dll which was throwing the error was msvcp90d.dll, I tracked it down to the log function (debigger said it couldn't be evaluated) :

  1. #include "log.h" (includes <iostream>, <fstream>, <string> and has the log structure)
  2.  
  3. RupLogger::RupLogger()
  4. {
  5. logfile.open("log.txt", ios::out);
  6. }
  7.  
  8. RupLogger::~RupLogger()
  9. {
  10. logfile.close();
  11. }
  12.  
  13. void RupLogger::log(string msg)
  14. {
  15. logfile << msg + " \n";
  16. }

So I decided to try something, the logger started below is logged correctly, but log still crashes.

  1. RupLogger::RupLogger()
  2. {
  3. logfile.open("log.txt", ios::out);
  4. logfile << "[SYS] Logger Started \n";
  5. }

So I thought there might be some strange issue with the logfile object's access or something so I tried below:

  1. void RupLogger::log(string msg)
  2. {
  3. this->logfile << "[SYS] Test Log \n";
  4. this->logfile << msg + " \n";
  5. }

Now this is where it gets freaky, now the debugger jumps into the ostream header and says the following is not evaluating (in bold):

Line 746:
	streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count
		? 0 : _Ostr.width() - _Count;

And um well now I'm just confused >.< and would like my program to run correctly again...
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 441
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 68
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: Heres a hard one: ostream include / msvcp90d.dll not working

 
0
  #2
Jun 26th, 2009
Well i copied your class, created a class definition out of whatever was given and used it and it worked fine for me.

  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. class RupLogger
  6. {
  7. public:
  8. RupLogger();
  9. ~RupLogger();
  10. void log(std::string msg);
  11. std::ofstream logfile;
  12. };
  13.  
  14. RupLogger::RupLogger()
  15. {
  16. logfile.open("log.txt", std::ios::out);
  17. }
  18.  
  19. RupLogger::~RupLogger()
  20. {
  21. logfile.close();
  22. }
  23.  
  24. void
  25. RupLogger::log(std::string msg)
  26. {
  27. logfile << (msg + " \n");
  28. }
  29.  
  30. int main()
  31. {
  32. RupLogger().log("Hi there");
  33. }

Don't see any reason why it should crash. Could it be something else causing the crash. Did you check the core file?
thanks
-chandra
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 6
Reputation: mOoEyThEcOw is an unknown quantity at this point 
Solved Threads: 0
mOoEyThEcOw mOoEyThEcOw is offline Offline
Newbie Poster

Re: Heres a hard one: ostream include / msvcp90d.dll not working

 
0
  #3
Jun 26th, 2009
Yea both ostream and the dll haven't been modified for months, and compiled and ran just fine a little while ago, what I don't get is why I'm getting the debug error inside of the ostream header file.

I am calling log through a pointer of the class, but it's been initialized and had it's constructor called before hand, besides if I put other functions in the log function it still runs correctly till it tries to write a line.
Last edited by mOoEyThEcOw; Jun 26th, 2009 at 5:51 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 6
Reputation: mOoEyThEcOw is an unknown quantity at this point 
Solved Threads: 0
mOoEyThEcOw mOoEyThEcOw is offline Offline
Newbie Poster

Re: Heres a hard one: ostream include / msvcp90d.dll not working

 
0
  #4
Jun 26th, 2009
Here's an interesting development, it appears that its an external call which is causing the crash, if I call log from the constructor it works but why would a call from something else fail, let alone inside the frikken header! >.<
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 6
Reputation: mOoEyThEcOw is an unknown quantity at this point 
Solved Threads: 0
mOoEyThEcOw mOoEyThEcOw is offline Offline
Newbie Poster

Re: Heres a hard one: ostream include / msvcp90d.dll not working

 
0
  #5
Jun 26th, 2009
This is the code that crashes it and how it is being called. Now I'm kinda new but as far as I know I'm doing that right.

  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. class RupLogger
  6. {
  7. public:
  8. RupLogger();
  9. ~RupLogger();
  10. void log(std::string msg);
  11. std::ofstream logfile;
  12. };
  13.  
  14. RupLogger::RupLogger()
  15. {
  16. logfile.open("log.txt", std::ios::out);
  17. }
  18.  
  19. RupLogger::~RupLogger()
  20. {
  21. logfile.close();
  22. }
  23.  
  24. void
  25. RupLogger::log(std::string msg)
  26. {
  27. logfile << (msg + " \n");
  28. }
  29.  
  30. static RupLogger* iLog;
  31.  
  32. int main()
  33. {
  34. iLog = &RupLogger();
  35. iLog->log("Hi there");
  36. }
Last edited by mOoEyThEcOw; Jun 26th, 2009 at 6:30 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,612
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 463
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: Heres a hard one: ostream include / msvcp90d.dll not working

 
0
  #6
Jun 26th, 2009
Temporary object. Use new keyword.
  1. iLog =new RupLogger();
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 6
Reputation: mOoEyThEcOw is an unknown quantity at this point 
Solved Threads: 0
mOoEyThEcOw mOoEyThEcOw is offline Offline
Newbie Poster

Re: Heres a hard one: ostream include / msvcp90d.dll not working

 
0
  #7
Jun 26th, 2009
doh! that makes sense thanks!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC