2011-05-20 04:20:26     Data access misaligned address violation while using free()

Document created by Aaronwu Employee on Aug 27, 2013
Version 1Show Document
  • View in full screen mode

2011-05-20 04:20:26     Data access misaligned address violation while using free()

Chandrashekhar Lavania (INDIA)

Message: 100772   

 

Hi,

 

I am using 2010R1-RC5 with mu BF527 based board.

 

I am trying to free some memory allocated via calloc. This is part of my release mechanism of my video capture application.

 

I do th following things:

 

if (munmap (buffers[0].start, buffers[0].length) == -1) { // unmaping

 

perror("munmap");

}

else {

 

printf("Munmap Successful\n");

}

 

free(buffers);

 

Declaration of ' buffers ' variable was done as::

 

struct buffer *buffers;

 

also

 

struct buffer {

        void * start;

        size_t length;

};

 

The issue is that my free command gives a Data access misaligned address violation error.

Note: The munmap is successful..

 

What might be causing this issue??

 

Regards,

Shekhar

QuoteReplyEditDelete

 

 

2011-05-23 03:13:50     Re: Data access misaligned address violation while using free()

Bob Liu (CHINA)

Message: 100796   

 

Please attach your test file.

 

And did you apply any patch against   2010R1-RC5 ?

 

Thanks,

QuoteReplyEditDelete

 

 

2011-05-23 08:21:40     Re: Data access misaligned address violation while using free()

Chandrashekhar Lavania (INDIA)

Message: 100800   

 

Hi Bob,

 

Thanks for replying and helping bring things into perspective. I tried to create a minamalized test application and the process solved my issue.

 

The problem was that my original app was a layered application, and I was trying to allocate memory in a higher layer and de-allocate it using free at a lower layer. The interaction was the one which was flawed. Also the memory packing at the lower layer was different because of the use of #pragma pack().

 

I resolved this issue by resolving the layer interaction as well as creating the same memory packing.

 

Still, thanks for the effort.

 

 

 

Regards,

 

Shekhar

Attachments

    Outcomes