I have a problem in my code and I don't know how to fix it. The problem appears only in target device.
Here is the fuction what causes the kern-exec 3 panic in my target device. aBuffer is a message which comes from the socket. It contains variable number of submessages which starts with ** and end with *
(example aBuffer = **submessage***submessage*.. and so on). Every submessage contains a struct and when the submessage is handled the information what is in it is sended to DecodeMessage().
Problem is that, when the execution goes to second round of the while loop and the i happends to be uneven dereferencing of resp causes a panic and that is because the uTotalLength is on the previous round even. When i is even there is no problem. Problem happends because the resp isn't a 32-bit multiple and that's why the code is valid in the emulator.
I have tried the Mem::Copy thing what is presented in "Developer Library/Tools and Utilities/Build tools guide/The native build targets". But still my code doesn't work in target.
Only thing what I could do is that I modify my server-side code and make my messages uTotalLength be always uneven. But that isn't so great idea.
But how I can fix this problem an make code work in target device?
Yes, it's definitely a memory alignment issue. x86 does not care about alignment (although accessing unaligned addresses is slower due to multiple reads/writes) while the ARM version raises an exception that manifests as KERN-EXEC 3.
Mem::Copy() if done right will help. Please tell what you have tried. Another common way to make it work is to wrap the message object in a TPckgBuf.