Thread: Code crash in vista not in XP

  1. #1
    Registered User
    Join Date
    Apr 2011
    Location
    Bangalore
    Posts
    20

    Code crash in vista not in XP

    Hi,

    I write a dll that is called by a java application. For some set of input the code is crash in vista but for same input its working in XP.
    Can any one plz tell me what is the possible reason and why it's happening.

    Thanks in advance,

    Shashi Kant Suman

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Could be gremlins, but without some code it will be difficult to know for sure...

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    You're presumably the sort of person who calls a mechanic and asks why your car won't go, without providing any further information.

    Without useful information (such as a small but complete sample of code that exhibits the symptom) it is not even possible to guess. There are many possible explanations.

    While you have probably decided it must be a problem with vista, a programming error on your part is the most likely explanation.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    OP: "Doc, my body hurts all over and I don't know what's wrong"
    Doc: "What do you mean?"
    OP: "It doesn't matter where I touch, it hurts like he**. I think I might be dying."
    Doc: "Your finger is broken..."
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  5. #5
    Registered User vee's Avatar
    Join Date
    Aug 2011
    Posts
    5
    Please provide a code Shashi..

  6. #6
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Attach the debugger to the java app on the vista machine and see what line of code was running when it breaks into the debugger.
    Make sure you load the symbols and have the source files handy.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  7. #7
    Registered User
    Join Date
    Apr 2011
    Location
    Bangalore
    Posts
    20
    All;

    I am sorry for not uploading any code, thought it might a standard problem with a standard solution !!

    The code is quite large and this in turn calls another dll. I built a separate C exe to call my code. When I ran this via the de-bugger, I noticed that the code crashed in the line

    Code:
    	fnpUnLoad = (fn_NP_Router_OSPF_UnLoadingDLL)GetProcAddress(hOSPFDLL,"fn_NP_Router_OSPF_UnLoadingDLL");
    	fnpUnLoad();
    	fn_NP_MPLS_UnLoadingDll();
    	free(NETWORK);              ----> CRASHES HERE
    	//NETWORK = NULL;
    	free(pszProcessingTime);
    	//FreeLibrary(hRouterDLL);      //free the primitive dll(RIP or OSPF)
    The NETWORK Sturcture is as follows

    Code:
    typedef struct stru_NC_Network
    {
    	int n_NC_NumberOfNodes;
    	int n_NC_NumberOfSwitches;
    	int n_NC_NumberOfHubs;
    	int n_NC_NumberOfRouters;
    	int n_NC_NumberOfAccessPoints;
    	int n_NC_NumberOfPhysicalMediums;	//Included by Sangeetha for tha device which has only physical layer
    	DEVICE *pstruNodelist[MAXNODES];//list of nodes
    	DEVICE *pstruSwitchList[MAXSWITCHES];//list of switches
    	DEVICE *pstruHubList[20];//list of hubs
    	DEVICE *pstruRouterList[MAXROUTERS];//list of routers
    	DEVICE *pstruAccessPointList[MAXACCESSPOINTS];//list of access points
    	DEVICE *pstruPhysicalMediumsList;	//list of physical mediums
    	int n_NC_SourceNode;		// used to form the lookup table for ATM/TCP included by sangeetha
    	int n_NC_DestinationNode;	// used to form the lookup table for ATM/TCP included by sangeetha
    	char *sz_NC_Path[100][100];	// used to form the lookup table for ATM/TCP included by sangeetha
    	double d_NC_SimulationEndTime; // time at which simulation ends
    	char *sz_NC_TraceDetails;		// used to store the fields which are going to write in a file
    	char *sz_NC_TraceName;	        // Name of the trace file
    	int n_NC_TraceFlag;
    	int sz_NC_WriteField[13];// used to set the variable which the user wants to set
    	int sz_NC_ASDeviceCount[MAXAUTONOMOUS];      // added on 6/1/2011 by swetha
    	int sz_NC_ASRouterCount[MAXAUTONOMOUS];      // added on 7/1/2011 by swetha
    
    };
    Hope this helps.

    Thanks

  8. #8
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    A crash on free() - assuming this is the standard C function named free() and not something else - most usually results from an error in preceding code.

    The most common cause of problems when calling free() is some form of pointer molestation in code BEFORE the call of free(). For example, dereferencing a NULL pointer, falling off the end of an array, etc. If one of those invalid operations interferes with data structures used internally by malloc() and free() to keep track of things, then the free() call may fail.

    So you are going to have to search through all of your code that is executed BEFORE the offending free() call.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  9. #9
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Also make sure you don't free any memory allocated within a dll outside the dll that allocated it (if dll A calls malloc then dll A should also be the one that calls free).

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    I'm guessing (from the scattering of "added by..." comments) that this is your work code.

    In which case, get your employer to purchase a few licences for one or more of these tools.
    Debugging tools - DevPartner - Micro Focus
    Insure++®: C/C++ Testing Tool, Detect elusive Runtime Memory Errors - Parasoft
    MicroQuill Software Publishing
    IBM Software - Rational Purify

    If the code has made several 1000's of malloc calls to that point, there is no practical way for you to examine each one of them in detail to make sure you're not doing something dumb. In a large program, you could do only a handful a day; it would take you years to finish the task, and your employer simply won't regard that as value for money (not to mention lost business for your product being at least 1 year late).

    What is an almost certain guarantee is that this will NOT be the only memory problem in that large code base. It's only the first one which has had a serious consequence when ported to a new platform. Others will be still hidden from view, waiting for the next small change (new OS, new compiler, random code addition or bug fix).

    The tools above will help you find them all, quickly and directly.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #11
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    Looks like somebody needs to give 'swetha' a refersher on hungarian notation.

  12. #12
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    pointer molestation
    Love it! Now I'm picturing pair programming with Chris Hansen.

  13. #13
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    Mmm, I thought a molestation was where these critters changed from one tunnel to another
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  14. #14
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    What compiler are you using? If Microsoft; Compile in debug mode and see what the exception/assertion text says.

  15. #15
    Registered User
    Join Date
    Apr 2011
    Location
    Bangalore
    Posts
    20
    All;

    Thanks for your suggestions. After debugging through the weekend, I found out that, we are passing 20 fields for this array, which could hold only 13.

    int sz_NC_WriteField[13];

    And resolved that this cause the crash. (Though I am not able to understand why the crash happens in the free() !!)

    However, further testing has thrown up new type error. The code crashes while running in release mode, but doesn't during de-bugging. Would welcome any ideas on what can be done ? Or let me know if I should attach any section of code?

    Also thanks for those links on the memory leak identification tools. I have begun evaluation and am currently exploring Rational Purify.

    Thanks
    Shashikant

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code runs on Windows 7 but not Vista?
    By gken05 in forum C++ Programming
    Replies: 7
    Last Post: 05-23-2011, 12:51 PM
  2. Update code for Vista 64
    By mdoland in forum C++ Programming
    Replies: 13
    Last Post: 06-02-2008, 04:34 AM
  3. why does my code crash
    By Anddos in forum C++ Programming
    Replies: 5
    Last Post: 01-18-2006, 01:26 PM
  4. crash my code.
    By caroundw5h in forum C Programming
    Replies: 7
    Last Post: 11-06-2005, 12:29 PM
  5. Why this code crash ?
    By MaaSTaaR in forum C Programming
    Replies: 4
    Last Post: 08-22-2005, 10:50 AM