Mbed TLS is now part of TrustedFirmware.org.

mbedtls_ctr_drbg_seed - memory allocation issue

Oct 1, 2017 23:55


I am trying to set up a random number generator, and I am experiencing an issue in which a SIGABRT is raised sometimes. The issue is intermittent, although the program itself is single-threaded and very short.

The basics look like this:

const char *pers = "generate random data";
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_entropy_context entropy;

int initialize() {
    int ret;
    ret = mbedtls_ctr_drbg_seed(    &ctr_drbg,
                                    (const unsigned char *) pers,
    return ret;

int main(void) {
    if (initialize() != 0) {
        printf("Couldn't initialize\n");
        return 1;
    return 0;

It is at the call to "mbedtls_ctr_drbg_seed" that I get this (sometimes):

malloc: *** error for object 0x7f8379002408: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug Abort trap: 6

I only perform the initialization once at the beginning of the program, but some of the time, I get the error, and other times I do not.

Any help in resolving this issue will be greatly appreciated!

Oct 2, 2017 05:41

Issue resolved! Just another PEBKAC.

Jan 18, 2018 07:01
Amit Shirbhate

Hi John,

For a similar, single threaded simple program, I am experiencing


Can you please suggest, what must be going wrong ?

May be in this case too PEBKAC however, not able to locate it. :)

Thanks, Amit