This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

memory prevented reading of target memory at

Error: memory prevented reading of target memory at 0x00000000.

what does this error means? been trying to figure this out for the past few days, but cant make this error go away.

i have a struct of complex number:
typedef struct {
   float re;
   float im;
} iq_complex_float;

then another struct that point to iq_complex_float:
typedef struct {
   iq_complex_float *data;
   int size;
} array_iq_complex_float


but when i declare array_iq_complex_float in my main, it's giving the above error.

where should i start debugging this?

lots of thanks beforehand :)

  • My suggestion is first look at the map file, and see if the linker put anything in the 0x000000  address

     

    If this is so, you need to change (or add) linker command file or/and the platform definition that defines the memory map

    Please get back to me with your observation about the map file

     

    Ran

  • You left out an important word in the error message, "map". It says the memory map prevented reading of target memory at 0x00000000.

    But in either case it tells you that you are trying to read from target memory at 0x00000000. You cannot do that.

    You have not initialized your struct. Once you initialize your data you will be able to view that data.

    What did you expect it to show?

    Regards,
    RandyP

  • sorry for the late reply. it's public holiday over here.

    anyway, i do not use any linker file. i just have the config file. will that matter? but i do use the RTSC tool that was generated automatically for my board for the memory map. see the screenshot.

  • well, one question i'd like to ask is, where would those be located on the memory?
    my guess would be the stack? or will it be the heap?
    anyway, in either case, i have already define the stack and heap to be located either on the L2SRAM or MCSRAM which is not at 0x00000000. if so, why would then it will try to access memory at 0x00000000?

    thanks

  • Hi,

    As RandyP saied, you forget to initialize the pointer to data. The ip_slot0 and iq_slot1 are corectly allocated on the stack, but unitialized, and.the member data is a pointer that point no-where, that is accindentaly equal to 0 (look at the size meber it also have a non-sense value).

    So the problem is not "where it is allocated", but that is not allocated at all. This is not an automatic  task for the linker: the program shoud explicitally do that.

  • hmmm

    that make sense. but iq_slot0 and iq_slot1 is actually initialized in line 189: bs->dGetIQ(&iq_slot0, &iq_slot1); where in there is:
        iq_slot0->size = length;
        iq_slot1->size = length;
        iq_slot0->data = (iq_complex_float*)malloc(iq_slot0->size*sizeof(iq_complex_float));
        iq_slot1->data = (iq_complex_float*)malloc(iq_slot1->size*sizeof(iq_complex_float));

    one thing that i notice though while stepping my code is i cant step into bs->dGetIQ(&iq_slot0, &iq_slot1); does that mean the program actually skip the function?

  • Just a hint

    The fact that you do not step in does not mean that the function is skipped.

     

    What I suggest you do is look at the disassembly and step in with assembly and not C, then you see if you skip or not

     

    (Step into assembly is the green multi-sides arrow)

     

    Ran

     

  • obed iskandar said:

    that make sense. but iq_slot0 and iq_slot1 is actually initialized in line 189: bs->dGetIQ(&iq_slot0, &iq_slot1); where in there is:

        iq_slot0->size = length;
        iq_slot1->size = length;
        iq_slot0->data = (iq_complex_float*)malloc(iq_slot0->size*sizeof(iq_complex_float));
        iq_slot1->data = (iq_complex_float*)malloc(iq_slot1->size*sizeof(iq_complex_float));

    one thing that i notice though while stepping my code is i cant step into bs->dGetIQ(&iq_slot0, &iq_slot1); does that mean the program actually skip the function?

    Well, so the problem is not related to the error reading at 0 signaled by the debugger. This is correct if iq_slot0->data is equal zero.

    Looking at image in your first post, I suppose you have not yet executed the cycle body once (note that also size looks very big).

    Maybe you are allocating too much memory and malloc() returns zero?

    Are you compiling with optimization on?

  • well the first image is just showing, but yes i do executed the cycle body once.  How do i know if i am allocating too much memory? and why would it make malloc to return 0?

    I did try compiling with optimization on but to no avail.

    one more problem, I tried to view the disassembly, but my CCS crash if i tried that. is it a bug? or something else.... i'm using ccs v5.0.1

    thanks again