Question about malloc and free

Arquer Stephane stephane.arquer at c-s.cnes.fr
Mon Nov 12 14:22:36 UTC 2007


Hello,

Rtems: 4.7.1
Bsp: i386-rtems4.7

I've a problem using malloc and free functions, a malloc is used in a
tool function that return a char* to create a string. The returned
address is 0x8 which is not a correct one.
Then, a call to free( name_sem ) crash due to
rtems_region_return_segment(rtems_malloc_heap, ptr);  (malloc.c:487)

I'd like to understand why this malloc return such address ?

I use the following code:
static int posix_bb_sem_get(S_BB_T *bb, int create){
	char* name_sem = NULL;
	int oflag = 0;
	if (create)
		oflag = O_CREAT | O_EXCL;	

	name_sem = bb_utils_build_sem_name(bb->name);
	bb->priv.posix.sem_id = (sem_t *)sem_open(name_sem, oflag |
BB_SEM_ACCESS_RIGHT);
	
	if ( bb->priv.posix.sem_id < 0) {
		LOG(BB_LOG_SEVERE, "BlackBoard::bb_create",
		    "Cannot create semaphore < %s >", name_sem);
		goto err;
	}
	free(name_sem);
	return BB_NOK;
}



Thanks.

sa




More information about the users mailing list