I have an applications that uses ADL library. There is a remark in ADL user guide that prohibites mixing lower-level APIs with ADL, but I still decied to try to use List Management API functions, and eventualy got an “Access Violation” exception in rte_kernel.exe process.
Is there a way to use list apis safely, or I have to implement lists myself?
And one more question. Here is a program that crashes rte_kernel.exe process when executed in RTE mode. Can someone tell what could cause this crash?
The program crashes when an item is removed from the list.
I found the reason of the crash. As it turns, wm_lstCreate stores a pointer to wm_lstTable_t structure, instead of copying it’s fields. This behaviour isn’t described in documentation (it could be just a little bit more obvious=) ), so I passed a pointer to a local structrue copy by mistake.
That is a classic ‘C’ programming error - nothing to do with Wavecom, ADL or the Open-AT list management!
The whole point of local variables in ‘C’ is precisely that they exist only inside the function, and only while the function is “active” - therefore any reference to any local variable from outside its scope is always an error!
It is also one of those errors that might not immediately cause any obvious problems - you might be “lucky” and your code might appear to “work”.
In fact, it should be considered very unlucky if such code does just happen to “work” - because it means that there is a latent bug just waiting to bite as a result of some (apparently) totally unrelated cause…!
Pointers in ‘C’ are extremely powerful - but this also makes them extremely dangerous!!
Please, don’t blame me for this mistake=)
First of all, the fragment of documentation that awneil cited concerns wm_lstAddItem function, not wm_lstCreate. There is nothing said about that funcTable must not be a local pointer.
And second, I used C only to write programs using WinAPI, where passing a local pointer to a structure is a common case. I think, some people may do this error, so this topic could be quite useful anyway.