|
Nope. DIdnt like that either.....
Thanks for the suggestion though.
ns
|
|
|
|
|
Arg. Someone please help because this is driving my crazy!
I have several apps that when I compile them using the win32 release configuration they bomb immediately. I'm downloading SP5 now, and I'm wondering if that will fix it. I've seen this before, and so have other devlopers where I work, but they all fixed it by shipping debug code. Unfortuately, that is not acceptible for the product.
If I can't compile it as release, is there a way to use the debug version, but instead of having the ASSERTS() in the MFC stuff produce a message box, have it bomb or exit right away? (Which would make it acceptible)
Many thanks in advance!
PS. I know it's not my code because according to the stack, it hasn't even entered my code yet:
MFC42! 73ddb4ec()
KERNEL32! 77e7eb69()
|
|
|
|
|
I am pretty sure it is your code . It doesn't have to enter your code to be your mistake. Maybe you are playing with some window handles and it will crash into a mfc code, not yours.
Have a look at this article, maybe you can find why it crashes.
Also you may try to include some debug information in the release mode and step into code to see what is causing the assert. Providing some code will be very helpful.
Best regards,
Alexandru Savescu
|
|
|
|
|
Well, adding to the complexity is the fact that it's an NT service, so it has no main() to speak of. It has an init() and a run() and a stop().
I put very simple MessageBox(NULL, "Running", "NT Service", MB_OK) statements at the very beginning of those and it dies before even hitting them.
What's making it even harder is then ir crashes, that's all thr stak info I have. If it's in my code, I can look at my map file an find what function did it, but I don't have map files ofr MCF42.dll!
|
|
|
|
|
Jason Hihn wrote:
I put very simple MessageBox(NULL, "Running", "NT Service", MB_OK) statements at the very beginning of those and it dies before even hitting them.
MessageBox ? In a service ? It may not appear.
Well, try LogEvent and see the event viewer...
Concussus surgo.
When struck I rise.
|
|
|
|
|
Jason Hihn wrote:
but they all fixed it by shipping debug code
Change jobs NOW. I mean it. You work with utter fools if they ever shipped debug code as a workaround for a bug they could not find.
Jason Hihn wrote:
PS. I know it's not my code because according to the stack, it hasn't even entered my code yet:
You should create an ofstream in your instance constructor, and write out some info to see where it is crashing. It's your code, don't worry about that.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
|
|
|
|
|
Jason Hihn wrote:
PS. I know it's not my code because according to the stack, it hasn't even entered my code yet:
MFC42! 73ddb4ec()
KERNEL32! 77e7eb69()
The fact that you're not on the call stack doesn't get you off the hook. E.G. It could be accessing memory that you released, trying to access a non zero terminated string, or an unavailable resource (ID defined but the actual resource has been deleted)
Debug mode has a lot of safeguards, can have different aligment (different code/object size) and can cause eg an extra int to be available in an array without overwriting data while release build overwrites essential data
so someone should fix the code
You can turn of the debug asserts by undefing _DEBUG, remove it from the project settings c/c++ preprocessor defines (I think this will however also cause linking to the release MFC dll's)
Better yet would be to identify the asserts and prevent them from happening (check it yourself first and then bomb or grace shutdown)
Good Luck
Rutger
|
|
|
|
|
The bounds chekers help me several times in that problem....
one solution is use the dr watson...
Compiles your code with mapfile, look into the file that leave the Dr watson, and llok for in the map file generated... This can help you...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Jason -
I wish you well my friend. You are about to embark on a painful but eventful journey. My best wishes are with you. I think u can be assured that the bug is in your code.
Sorry I sound like that, but I have been through the hard knocks of debugging a major bug in the release build. I hope you dont have complier optimizations turned on, because then even Dr Watson will confound you. Turn compiler optimizations off and see if you can reproduce the problem. You can turn it back on after finding the bug.
The book "Debugging Windows Applications" (MIke Wooding and Everett Mc Kay) was of immemse use to me. This is where tools like BoundsChecker will prove to be invaluable.
The reward : After you hunt down the bug, you can go out and have a beer. That will be the best beer u ever had.
-
Vivek
|
|
|
|
|
same thing happened to me before, it is problem of libraries used.
did you use database in your apps?
please post a little bit more info: i.e. com, dcom, etc.
includeh10
|
|
|
|
|
Well I've done some investigating...
Looks like it does actually run my code, but only the constructors run. Those are filled with bounds checked string copies and integer initializations. All contructors return ok.
Where the problem lies is when it tries to call StartService() which then goes to ServiceMain(), then to Initialize().
Somehow on it's way to calling StartService, it is bombing. The thing is I can't figure out what is begin called between the constuctors and StartService.
Arg!
PS. It's just a win32 app with sockets (NOT MFC! I'm using wrappers from W3MFC) and a MySQL library.
|
|
|
|
|
When you switch from debig to release mode, rather than inherit settings from the debug mode, (even such no brainers as /subsystem:XXXXXXX) it starts from some dumb defaults which can have nothing do to with your debug mode program.
I had to change from /subsystem:windows to /subsystem console. The really weird thing (and for this I blame Microsoft) is that I had no WinMain(), only a main().
With /subsystem:windows I should have gotten a warning at the least. Now, even so, I'd expect my program to crash (or nto even compile) because there was no WinMain, BUT SOME HOW ONE GOT SUPPLIED TO IT. I accidentaly I ran it on my PC (remember it's a service, it's supposed to be started that way, plus I'm running Win98, which doesn't have full NT-Services) and it put me into a WinMain. Where I came from, I don't know... then I remembered to check the subsystem.
Many thanks to all you who tried to help!
|
|
|
|
|
Jason Hihn wrote:
because there was no WinMain, BUT SOME HOW ONE GOT SUPPLIED TO IT
MFC supplies one. Are you using MFC ?
Concussus surgo.
When struck I rise.
|
|
|
|
|
Jason Hihn wrote:
BUT SOME HOW ONE GOT SUPPLIED TO IT. I accidentaly I ran it on my PC (remember it's a service, it's supposed to be started that way, plus I'm running Win98, which doesn't have full NT-Services) and it put me into a WinMain. Where I came from, I don't know... then I remembered to check the subsystem.
AFAIS from your original post, your app is linked against MFC42.dll. Are you sure you are not using MFC?
I only ask, because it sound quite suitable to me, that MFC42.dll contains your "mysterious WinMain()".
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Is it possible to get the main window which associated with an
instance handle (HINSTANCE)? Or there's no such association?
Any help will be personally blessed!
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
I'm having a strange problem with the STL map.find(). I have a function which I search for an item's existance with a find() before inserting. If I don't find it, I insert it. Trouble is, when an item already exists in the map, both the find() and count() never report it. Also, the insert() lets me add a duplicate key. Below find declarations, code, and debug output.
// declarations
typedef struct ImportDataType
{
CString Item;
CString Value;
char Type;
long ReplicationID;
} ImportDataType;
typedef vector<importdatatype> dataVector;
typedef map<const char="" *,="" datavector=""> importData;
map<const char="" *,="" dataimportdata::datavector="">::const_iterator mapIter;
int i = dataMap.count(m_currentEID);
int j = dataMap.size();
TRACE ("\nIn AddDataItem, b4 map.insert(), size of Map = %d\n",j);
TRACE ("Number of items in the Map with key of %s = %d\n",m_currentEID,i);
mapIter = dataMap.find(m_currentEID);
if (mapIter != dataMap.end())
TRACE ("B4 insert, key found in map!\n");
else
TRACE ("B4 insert, key not found in map!\n");
for (mapIter = dataMap.begin();
mapIter != dataMap.end(); mapIter++)
{
TRACE ("Key from Map = %s\n", (*mapIter).first);
}
dataMap.insert(make_pair(m_currentEID, dataVector));
mapIter = dataMap.find(m_currentEID);
if (mapIter != dataMap.end())
TRACE ("After insert, found key in map!\n");
else
TRACE ("After insert, key not found in map!\n");
i = dataMap.count(m_currentEID);
j = dataMap.size();
TRACE ("\nIn AddDataItem, after map.insert(), size of Map = %d\n",j);
TRACE ("Number of items in the Map with key of %s = %d\n",m_currentEID,i);
for (mapIter = dataMap.begin();
mapIter != dataMap.end(); mapIter++)
{
TRACE ("Key from Map = %s\n", (*mapIter).first);
}
The partial output from running this shows the problem. Note the key values are being printed before the insert is done. The key 6748 does exist, but the map.count() and map.find() are not reporting it. Note in the last dump of the map keys that 6748 is there twice! What am I doing wrong?
In AddDataItem, b4 map.insert(), size of Map = 3
Number of items in the Map with key of 982000006006748 = 0
B4 insert, key not found in map!
Key from Map = 982000006003798
Key from Map = 982000007172537
Key from Map = 982000006006748
After insert, found key in map!
In AddDataItem, after map.insert(), size of Map = 4
Number of items in the Map with key of 982000006006748 = 1
Key from Map = 982000006003798
Key from Map = 982000007172537
Key from Map = 982000006006748
Key from Map = 982000006006748
Any ideas are appreciated as to why this does not work!
Thanks in advance,
Bob
|
|
|
|
|
There is something wrong with your code. How do you sort your items? You have to provide a < operator so the map can insert and lookup your items. And also, please format your code and change < and > with < and > so we can see your code better.
Best regards,
Alexandru Savescu
|
|
|
|
|
Alex,
Thanks for your response, sorry, I don't know how to format my code for the post, can you please tell me how? Since I don't provide a sorting criterion when I define my map, it should use the default less <>? I don't really understand the sorting criterion very well. I can see my items don't appear to be sorted. All I want to do is insert items and find items. How should I specify it?
thanks,
Bob
|
|
|
|
|
Use the <pre> tags. You can use them on the formatting bar just above the smileys. Also you can preview the messge before it gets posted.
In a map items will be sorted by key. If you use int as keys then you need not provide a < operator. But if your are using some structs then you definitely must give a comparison method.
Best regards,
Alexandru Savescu
|
|
|
|
|
I am using a key of const char *, the data is struct. How would I specify a comparison method for char *?
thanks,
Bob
|
|
|
|
|
Taking a closer look the HTML source page I found this
typedef map<const char *, dataVector> importData;
So you are using some const char* as string. Using less on them will compare pointers and of course that your map will not look as you expect. You must compare them with strcmp . Or, easier use CString as key. It has a < operator defined that does good job.
Best regards,
Alexandru Savescu
|
|
|
|
|
Alex,
Making the key a CString worked!!! Thank you very much for your help!
Bob
|
|
|
|
|
Of course it did, I just explained the reason.
If you want to use const char* (maybe for portability) then here is an exameple from the SGI documentation
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
int main()
{
map <const char*, int, ltstr> mymap;
}
Best regards,
Alexandru Savescu
|
|
|
|
|
I need make a library of 16 bits in vc++. I don`t know the statements to use.
Thank in advances
|
|
|
|
|
I think C++ 1.5 was the last to support 16 bits. They still give it as part of some of the MSDN subscriptions.
Ain't nobody ever told you : There ain't no sanity clause .Groucho Marks
|
|
|
|
|