Reputation: 3888
I didn't use C for long time and I don't remember if it is possible to create a thread from another thread. If I try, I get this error:
sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Aborted
Is there a workaround to lunch a thread from another one? Is there anything special I should set in attributes to make it work?
Thanks
PS: I should use only pthread and not fork() as required by an university project
Upvotes: 0
Views: 1220
Reputation: 215617
This error has nothing to do with threads. It's an indication that you've corrupted the memory used by malloc for bookkeeping purposes, probably by overflowing a buffer in a block you obtained from malloc.
Any thread can create new threads; there is no restriction on that.
Upvotes: 3