System Access violation exception:Attempted to read or write protected memory..Help!

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

System Access violation exception:Attempted to read or write protected memory..Help!

Hello,

I have CAN Dll program for my application,which was separately used.Now I have included the Drivers program into my application Program and I am having this error System Access Violation Exception:Attempted to read or write protected memory.Please help me what is error for.i am attaching the Dll code and Application code which is throwing this error.

memcpy(&uMsgId,MsgId,4);
UI64 RawCanData;
if(RcvVal == 0){ //there is data in the queue
switch(uMsgId){ //switch statement that parses the incoming message based ON the message id.

So this program builded successfully and while executing it I am getting the error as

Receive thread quit Unexpectedly
system Access violation Exception:Attempted to read or write protected memory.This is often an indication that other memory is corrupt at
xlreceive(int32,Uint32*,s_xl_event*)
at receive_data(Byte*data_output,int32*MsgId,Int32 g_xlPortHandle).

I have CAN Dll program for my application,which was separately used.Now I have included the Drivers program into my application Program and I am having this error System Access Violation Exception:Attempted to read or write protected memory.

Please use proper code tags. The code you posted is unreadable.

Please help me what is error for.i am attaching the Dll code and Application code which is throwing this error.

Runtime errors require that we run the program and duplicate the error with the data that you're using. It doesn't matter what the code is, if we don't know what data is being used, the flow of the program, the value of the variables, etc. then it's up to you to debug the program.

Even the code you posted has unknowns. What is "g_xlPortHandle"? What are the values? Is the code multithreaded? But asking and answering all of these questions still require you to run and debug your application.

So this program builded successfully and while executing it I am getting the error

Having a program build successfully means nothing except that an executable was produced. It doesn't mean that the program will run successfully. That is when you must start debugging your code.

So if you believe that the error is there, why are you not debugging to see what is going on? What is "xlRecieve"? If you write a program, it is required that you know how to debug the programs that you have written. Otherwise you either gain the proper experience in debugging your own programs, or get someone else to write and debug the programs for you.

In any event, that line of code shows us nothing. You have "g_xlPortHandle" -- is that a valid value? You are passing the address of msgsrx? Is that a valid address? You are passing the address of &xlEvent. Is that a valid address? If your answer to all three is "yes", then what else can we do for you except to run your program ourselves with the data that you're using? If they are all valid, then the problem is in xlRecieve, or you corrupted memory long before that call is made and that line of code is where your application finally breaks down, or your program is multithreaded and you are not using the proper synchronization or similar problem.

That's why you need to debug the program, as you have the entire code and application, and can duplicate the error.