|
|
Sure Hamid!
I am using both Windbg and Visual Studio to debug this. Any comments or ideas to my original question?
regards,
George
|
|
|
|
|
Did you use of GetProcAddress on your code?
|
|
|
|
|
No, Hamid! The error happens when I tries to access a member variable of an instance of a class allocated on the heap. Any ideas?
regards,
George
|
|
|
|
|
Can you show your code that it generated this error?
|
|
|
|
|
Thanks Hamid,
The code is,
foo = someconstant;
The exception reports the accessing for foo variable throws the exception, any ideas?
regards,
George
|
|
|
|
|
With minimum minimum info I must answer to you?
|
|
|
|
|
What additional information do you need to debug this issue, Hamid?
regards,
George
|
|
|
|
|
Did you check your pointers?
|
|
|
|
|
Is this variable a member of a class ? If yes, check whether your class instance is valid.
Suppose you have a pointer to one of your class which is initialized to NULL. If you call a function on this instance, the function will get called and the crash will only appear when you access a member of your class. In general, it looks a bit weird at this level of the code but if you go one level higher in the callstack, you can immediately check the problem.
This is something that happens quite frequently and is a bit disturbing the first time.
|
|
|
|
|
Hi Cedric!
Is this variable a member of a class ? => yes.
How to check "whether your class instance is valid"?
regards,
George
|
|
|
|
|
George_George wrote: How to check "whether your class instance is valid"?
As I explained in my previous message: at the point of the crash (so when you assign the variable), check the call stack and go one level higher (so at the point where you call the function on your class instance). There check if the pointer is valid. Of course this is only the case if you are working with a pointer to your class.
If that's not the problem, then you have to post some more explicit code because it is almost impossible to help you.
|
|
|
|
|
Hi Cédric!
I find the instance variable itself is fine, but the field (member variable) of the instance is wrong with access violation error.
The member variable's address is 0x00d4cff0, and it is where the error occurs (exception dialog box reports the error).
Here is what I am using Windbg to get the information for the memory at this address. Do you have any further ideas what is the root cause of this issue? What means "PAGE_NOACCESS"?
0:001> !address 0x00d4cff0
00d0d000 : 00d0d000 - 00040000
Type 00000000
Protect 00000001 PAGE_NOACCESS
State 00010000 MEM_FREE
Usage RegionUsageFree
regards,
George
|
|
|
|
|
Please post some code about the function itself and the code where you call the function (and no pseudo code please).
|
|
|
|
|
Examine the this pointer (you can for example expand the this node in the debugger's watch window and look at the members, if you see a bunch of question marks and/or strange values (like, extremely high values for integers or negative numbers where there should ne none) then your this pointer is pointing somewhere it should not.
|
|
|
|
|
I'd guess the problem is a NULL pointer. For example, code like this would result in the same problem:
char *pMem = NULL;
pMem[5] = 0;
The ???????? indicates that there is no memory mapped at that virtual address (thus the exception).
Steve
|
|
|
|
|
Run the demo program at http://www.codeproject.com/KB/tree/colortreectrl.aspx[^], and then click "Start->Settings->Taskbar and start menu" , do nothing and then click "OK" button , you will find that the expand button in the demo program became a little smaller. What's the reason?
|
|
|
|
|
When in my application i use functions exported form a dll what happen to my application ? The dll is mapped in my application memory? And if yes, when does this happen ? On application startup or when the dll is called for the first time?
|
|
|
|
|
|
Sorry, actually i meant to post to the original question.
Usually the dlls loaded and mapped into process memory space during application startup. Well, if you mark the dll as "delayed loading dll" then that particular dll will be loaded only during the "first call" to any of the dll exported function. And you can avoid LoadLibrary() and GetProcAddress() functions if you really want the dll to be loaded during runtime.
Well check these links about - How to mark a dll as delayed loading dll[^] and Delayed Loading Dll article[^] in codeproject.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
modified on Sunday, November 23, 2008 7:00 AM
|
|
|
|
|
franco nero wrote: if yes, when does this happen ? On application startup or when the dll is called for the first time?
At application startup, unless you "late bind" to the DLL (i.e. load
the DLL with LoadLibrary()), in which case it happens when LoadLibrary()
is called.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Usually the dlls loaded and mapped into process memory space during application startup. Well, if you mark the dll as "delayed loading dll" then that particular dll will be loaded only during the "first call" to any of the dll exported function. And you can avoid LoadLibrary() and GetProcAddress() functions if you really want the dll to be loaded during runtime.
Well check these links about - How to mark dll as delay loading dll[^] and Delayed Loading Dll article[^] in codeproject.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
modified on Sunday, November 23, 2008 8:26 AM
|
|
|
|
|
Hi,
i need some expert design guidelines for a real time 3D graphics application using Visual C++. These advices may be high level for extensibility or low level for performance issues. i’m getting confused at some parts of design like syncronization of frame loop with real time data and processing realtime data without buffer overruns etc,, so let me explain application details and some points that needs your expertise.
From now on i will use the following acronmys;
- APP, main application (an SDI MFC executable - .exe),
- DllMan, an MFC Extension DLL ( .dll) that includes a Plug-In Manager and Base Plug-In and utility classes that is statically linked to APP,
- PlugIn#N, a number of MFC Extension DLLs (PlugIn#1.dll, PlugIn#2.dll) that is managed and dynamically linked by DllMan which includes derived Plug-In Classes and Socket and DB utiliy classes to get realtime UDP packets over network and process them, update entity states and record incoming data to Database for offline replay/playback.
APP will statically be linked with DllMan and at startup DllMan dynamically loads up PlugIn#N. APP will display a 3D view of entities by using a 3D Scene graph and rendering library. User will zoom in/out, pan on the screen and be enabled to start/stop recording realtime data and replay all mission by using recorded data by offline.
In order to maintain a reasonable frame rate and realtime data sync, i need your expertise regarding how should i design APP, DllMan and PlugIn#N?
Let me tell you abit about my PlugIn#N design. Each plug-in module contains a derived class which inherits some basic implementation and interface from base plug-in class in DllMan module. Each plug-in basically implements an entity that will be drawn on 3D View. Entity data is coming from network at 50 hz rate by UDP packets. So by design each entity has its own plug-in module and get its realtime data on its own UDP port. There will be thread-safe Queue to work as a data packet buffer, a worker thread to process data packets, update entity state and record incoming packet to database. During realtime operating mode data comes from network but while offline packets shall be queued from Database records and a similar processing will take place. During offline replaying, user shall have full control on 3D scene by jumping, rewinding any instant on recorded mission data. Bu in realtime mode user will just enable to zoom in/out on 3D scene.
1- My first question will be about realtime data processing. Lets consider there is only one plug-in module PlugIn#1 loaded and UDP packets are coming with (50 hz ). To prevent buffer overruns on Recv() what should i do? Should i put received bytes ( a message structure indeed) immediately into a thread safe Queue and notify waiting worker thread to process incoming data?
2- Second question is about realtime data synchronization. APP side will have a frame loop to update frame data and draw. Since most of our frame data is inside PlugIn#N because of that entities are created under each plug-in module automatically and put inside a list managed by DllMan. APP will request DllMan to get entities updated for each frame to draw 3D scene. APP will use DllMan to iterate each PlugIn#N each frame. So what gets me really confused is that. Should there be a syncronization between APP+DllMan & PlugIn#N since there may be a worker thread inside PlugIn#N. What should be the relation between this kind of application to properly render entities with each incoming realtime data. i’m getting confused regarding how is it possible to use all data by APP and no state overlap will be prevented between next incoming data and current state?? This point is so important for me to understand.. Pls could you explain in detail if you have any experience?
3- What should be done to maintain a reasonable overall frame rate like 30 fps? Should i use CwinApp::OnIdle()? Or should i use some high frequency timing mechanism? Or any worker threads at APP side other than main thread?
4- What happens if APP tries to achieve a 30 Hz frame rate but 50 hz realtime data is coming from network? Is it possible to handle such data rate? if possible i’m wondering how? Since 3D scene draw time is full of terrain, 3D models, 2D Overlays and geometries?
5- What happens the runtime performance if more than one PlugIn#N module is loaded? Since each PlugIn#N module architecture will be similar so each one will have Queues threads db connections..etc should i consider on overall achitecture? Since plug in architecture is considered to achieve flexibility whenever new mission entities are required and building a new entitiy would have no effect on APP+DllM side in theory. By this way we would get rid of modifying working part to integrate a new module in the future. But that architecture will make no sense if 3D performance is not reasonable.
thanks in advance
for your patience and precious comments..
regards,
atilla.
|
|
|
|
|
Hi i using an application in that i am using char**
Usually in UNICODE settings we can represent
char* as LPCTSTR my question is How to represent char** in UNICODE
please help me
Thanks in advance
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|
I'm not sure what you mean but i think what you need is WCHAR or wchar_t (or maybe simply short). So WCHAR** or wchar_t** (or short**), LPCWSTR.
|
|
|
|