|
Hi all,
I receive the following error:
Unhandled exception at 0x0045b287 in updCnf32.exe. 0xC0000005: Access violation writing location 0x00666e63.
Code (xutilty : compiler open this file):
inline void __CLR_OR_THIS_CALL _Container_base::_Orphan_all() const
{
_Lockit _Lock(_LOCK_DEBUG);
if (_Myfirstiter != _IGNORE_MYITERLIST)
{
for (_Iterator_base **_Pnext = (_Iterator_base **)&_Myfirstiter;
*_Pnext != 0; *_Pnext = (*_Pnext)->_Mynextiter)
(*_Pnext)->_Mycont = 0;
*(_Iterator_base **)&_Myfirstiter = 0;
}
}
This is my code:
for(int i=0; i < (int)getFileNamesString.size(); i++)
{
getFNamesString = CIniFile::GetSection(getFileNamesString[i], applicationFname);
for(int i=0; i < (int)getFNamesString.size(); i++)
cout << "File Names -> " << getFNamesString[i].Key.c_str() << "=" << getFNamesString[i].Value << endl;
}
string FileName = getFNamesString[0].Value;
string updateFName = getFNamesString[1].Value;
printf("Creating Directory\n");
TCHAR szDirPath[] = TEXT("C:\\Test\\");
if (!CreateDirectory(szDirPath, NULL))
{
printf("Could not create new directory.\n");
getch();
return -1;
}
else
printf("Directory Created...\n\n");
strcat((char*)szDirPath, (const char*)updateFName.c_str());
char lpExistingFileName[BUF_SIZE];
char lpNewFileName[BUF_SIZE];
strcpy((char*)lpExistingFileName, (const char*)updateFName.c_str());
strcpy((char*)lpNewFileName ,(const char*)szDirPath);
if(CopyFile((LPCTSTR)lpExistingFileName,(LPCTSTR)lpNewFileName,FALSE))
printf("File was copied successfully...\n");
else
printf("File copy failed....\n");
bool SecRc = false;
vector<string> getSecNameString = CIniFile::GetSectionNames(FileName);
for(int i=0; i < (int)getSecNameString.size(); i++)
{
vector<CIniFile::Record> getSecString = CIniFile::GetSection(getSecNameString[i], FileName);
for(int i=0; i < (int)getSecString.size(); i++)
{
if (CIniFile::SetValue(getSecString[i].Key,getSecString[i].Value,getSecString[i].Section,updateFName))
SecRc = true;
else
SecRc = false;
}
}
if (SecRc)
printf("\nSuccess...\nPress any key to continue....");
else
printf("\nFailed...\nPress any key to continue....");
getch();
return 0;
Many thanx ( .. ..)
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Did you use your debugger to see where the problem in your code is ? Can you tell us more about where it happens and what are the value of your variables at this point ?
|
|
|
|
|
Thanx for the reply Cedric,
The exception happens right at this point:
As I press any key, for the getch() the exception occurs.
getch();
return 0;
}
Does this help?
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I get a feeling that the stack has become corrupted. Check the memory allocations. If you can't find it that way, try to comment out portions of the code until you can pinpoint the location of the source of the error.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
O.k I have done what you said and I have located the place where it happens, can you see anything wrong here:
strcat((char*)szDirPath, (const char*)dtStamp);
char lpExistingFileName[BUF_SIZE];
char lpNewFileName[BUF_SIZE];
strcpy((char*)lpExistingFileName, (const char*)updateFName.c_str());
strcpy((char*)lpNewFileName ,(const char*)szDirPath);
if(CopyFile((LPCTSTR)lpExistingFileName,(LPCTSTR)lpNewFileName,FALSE))
printf("File was moved successfully...\n");
else
printf("File move failed....\n");
Many thanx
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Got it ...
#define BUF_SIZE 1000
char szDirPath[BUF_SIZE] = "C:\\CNF_Update_Transactions\\";
:->
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Yes, you did.
I couldn't verify your code, since you didn't supply the variable declarations.
But anyhow, the problem is fixed, that's the main thing.
And you got a lesson about what happens in case of a stack corruption. Strange things happens...
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Many thanx Kakan
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I'm glad I could help you out.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
hi,
I've a question.
Can use a class written in a file (fileA.cpp) and use the funtion from the class in another file(fileB.cpp) for example?
|
|
|
|
|
Offcourse.. just include the header file containing the definition of class most probably fileA.h, define an object wherever u want to use the functions of the class and call them. Simple ehh :P
|
|
|
|
|
hi friends !
please do anyone tell me why we put & character in copy constructor.
i know it is syntax. but i need a little explanation
thanks
|
|
|
|
|
Similar question[^] has appeared on this forum few days before. It should give you idea.
|
|
|
|
|
I am getting an exception while start running my project. i am included some 6 dll's and each dll is working and verified.
The error message shows,
"The application failed to initialize properly (0xc0000142). Click on OK to terminate the application"
"Unhandled exception in LFATE.exe (NTDLL.DLL): )xc0000142: DLL Initialization Failed"
|
|
|
|
|
|
I would guess DLLMain is returning FALSE in response to the DLL_PROCESS_ATTACH notification and you're statically linking to the DLL.
Steve
|
|
|
|
|
I am linking 10 dlls statically. how can i figure out?
|
|
|
|
|
Just run the app in a debugger and watch the output. I made a test app to reproduce the problem and here's the output MSVC6 produced:
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded symbols for 'C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll'
First-chance exception in StaticLinkProblem.exe (NTDLL.DLL): 0xC0000142: DLL Initialization Failed.
The line in question is "Loaded symbols for 'C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll'"; the last DLL load reported before the problem occured.
Steve
|
|
|
|
|
Thankx. But i am getting error message as follows...
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\hp34401_32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\visa32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\NiViSv32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt20.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\DP5022DLL.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\DP5301DLL.DLL', no matching symbolic information found.
Loaded 'D:\DP PROJECTS\PEA0430_SEAKING_1\LFATE_APP_MODIFIED_KARTHI\LFATE_Modified ver-0.11_13_12_06_Karthi\Debug\DP5031DLL.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\DPCPCI4509DRV.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\DPcPCI4035.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\DPcPCI4140.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\DPcPCI4158Drv.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\DPcPCI4305.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\DPcPCI2709Drv.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\DPcPCI4341.dll', no matching symbolic information found.
Loaded symbols for 'C:\WINDOWS\system32\MFC42D.DLL'
Loaded symbols for 'C:\WINDOWS\system32\MSVCRTD.DLL'
Loaded symbols for 'C:\WINDOWS\system32\MFCO42D.DLL'
Loaded 'C:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\oleaut32.dll', no matching symbolic information found.
First-chance exception in LFATE.exe (NTDLL.DLL): 0xC0000142: DLL Initialization Failed.
Whether can i concluded the probelm in
C:\WINDOWS\system32\oleaut32.dll file. is this system dll?
How can i solve it?
Reg,
Parthiban
|
|
|
|
|
Try turning on "loader snaps". Follow these steps:
1. Download and install the latest version of WinDBG[^].
2. Select “Start”->”All Programs”->”Debugging Tools for Windows”->”Global Flags”.
3. The “Global Flags” dialog appears. Select the “Image File” tab.
4. In the “Image: (TAB to refresh)” edit control enter your exe name with extension; not the full path, just the filename.
5. Press the “Tab” key.
6. Tick the “Show loader snaps” tick box.
7. Press the “Apply” button.
8. Run the application in a debugger. Here’s some sample output:
Loaded 'ntdll.dll', no matching symbolic information found.<br />
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.<br />
Loaded symbols for 'C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll'<br />
[9b4,f48] LDR: Real INIT LIST for process C:\Projects\Scratch\StaticLinkProblem\Debug\StaticLinkProblem.exe pid 2484 0x9b4<br />
[9b4,f48] C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll init routine 100011C0<br />
[9b4,f48] LDR: ProblemDLL.dll loaded - Calling init routine at 100011C0<br />
[9b4,f48] LDR: DLL_PROCESS_ATTACH for dll "C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll" (InitRoutine: 100011C0) failed<br />
LDR: LdrpInitializeProcess - Failed running initialization routines; status c0000142<br />
LDR: _LdrpInitialize - call to LdrpInitializeProcess() failed with ntstatus c0000142<br />
First-chance exception in StaticLinkProblem.exe (NTDLL.DLL): 0xC0000142: DLL Initialization Failed.
9. When done un-check the “Show loader snaps” tick box and press "OK".
The line of interest is the following:
[9b4,f48] LDR: DLL_PROCESS_ATTACH for dll "C:\Projects\Scratch\StaticLinkProblem\Debug\ProblemDLL.dll" (InitRoutine: 100011C0) failed
Steve
|
|
|
|
|
In my program, I have the following code.
struct Stru_A{
char Name[30];
int Age;
}
struct Stru_A * pA1 = new Stru_A();
struct Stru_A * pA2 = new Stru_A();
strcpy(pA1->Name, pA2->Name);
'BoundsChecker' reports the following error,
You have passed an invalid memory address as a pointer to a Windows API function.
However, the program can compile and run successfully ignoring the above BoundsChecker error.
I cannot understand why BoundsChecker report the error.I wonder if ignoring of the error is a correct way.
|
|
|
|
|
As long as you've initialized the Name member of struct Stru_A then there is no problem
in the code you've posted.
If Name is uninitialized then there's a problem
|
|
|
|
|
Thanks,
Yes, I did not initialze 'Name'.
One further question is if uninitialization of 'Name' may cause the following error:
************************
Microsoft Visual C++ Runtime Library
---------------------------
Runtime Error!
Program: C:\PatternDecompose_1_061220\Debug\testing.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
************************
Currently, my program can run successfully with small-scale dataset. However, when it run with a slightly large dataset, the above message will pop up and the program terminates. To solve this problem, I use BoundChecker to test my program and found the error about
<br />
strcpy(pA1->Name, pA2->Name);<br />
|
|
|
|
|
That error usually happens when you're just out of memory (which seems likely, as you mention using a large data set)
You'll probably need to optimise your workflow, so that you don't need to keep so much in memory.
If you don't seem to have a high memory usage when it dies, the other option is extreme memory fragmentation, which can be a much trickier beast to solve (you'd probably want to implement some sort of memory pooling)
|
|
|
|
|
Sorry , I forgot a line in the illustration
struct Stru_A{
char Name[30];
int Age;
}
struct Stru_A * pA1 = new Stru_A();
struct Stru_A * pA2 = new Stru_A();
strcpy(pA2->Name, "123");//<====== omitted line
strcpy(pA1->Name, pA2->Name);
Does it make sense with the originaly omitted line added?
|
|
|
|