Skip to content

Conversation

deepikabhavnani
Copy link

Description

Compilers allocate some section of memory without using wrapper function, which is later freed when wrappers were initialized. Since the allocate memory didn;t contain wrapper header the pointer got corrupt when calling to free.

This implementation of signature addition during malloc and signature check during free helps in freeing the memory allocated by wrapper functions properly and also the internal memory allocated by compilers (without malloc wrappers).

Resolves: #7912

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Breaking change

@deepikabhavnani
Copy link
Author

@ccli8 @cyliangtw - Please review

@NirSonnenschein
Copy link
Contributor

/morph build

@mbed-ci
Copy link

mbed-ci commented Oct 3, 2018

Build : SUCCESS

Build number : 3226
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8062/

Triggering tests

/morph test
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Oct 4, 2018

@NirSonnenschein
Copy link
Contributor

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Oct 4, 2018

@deepikabhavnani
Copy link
Author

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Oct 4, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 6, 2018

Please rebase, will restart testing

Deepika added 2 commits October 8, 2018 07:37
malloc guarantees aligned memory. If we add an alignment here, we are adding
additonal unused 4 bytes. Each allocator has its own 4/8 byte header
(GGC / ARM have 4 bytes).

So if user request for 8 bytes of memory stats will add 8 + allocator 8.
However if we remove the alignment in stats header, allocator will consider
add 4 bytes to 12 byte request and zero padding.

It will be beneficial to leave the padding to allocator.
Compilers allocate some section of memory without using wrapper function,
which is later freed when wrappers were initialized. Since the allocated
memory didn;t contain wrapper header the pointer got corrupt when calling to free.

This implementation of signature addition during malloc and signature check during
free helps in freeing the memory allocated by wrapper functions properly and
also the internal memory allocated by compilers (without malloc wrappers).
@deepikabhavnani
Copy link
Author

Please rebase, will restart testing

@0xc0170 - Rebase done. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants