arm/183926: Crash when ctrl-c while process is enter

Howard Su howard0su at gmail.com
Wed Nov 13 13:30:00 UTC 2013


>Number:         183926
>Category:       arm
>Synopsis:       Crash when ctrl-c while process is enter
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-arm
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 13 13:30:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Howard Su
>Release:        -Current
>Organization:
>Environment:
FreeBSD beaglebone 11.0-CURRENT FreeBSD 11.0-CURRENT #9 42a79a9(dtrace_arm)-dirty: Tue Nov 12 21:56:17 CST 2013     howardsu at FreeBSD:/usr/home/howardsu/usr/obj/arm.armv6/usr/home/howardsu/usr/freebsd/sys/BEAGLEBONE  arm

>Description:
consistent repro a crash related signal deliver and mutex/cond operation in arm platform.

I notice this when I was play with dtrace arm port from gonozo. the _sleep function is a simpler version of dtrace_sleep in libdtrace. In case you need a real case, please refer that file @ cddl/contrib/opensolaris/lib/libdtrace/dt_work.c.
>How-To-Repeat:
Compile and run the attached C code.

Press Ctrl-C when shows "enter".

>Fix:


Patch attached with submission follows:

#include <stdio.h>
#include <pthread.h>
#include <signal.h>

pthread_cond_t cv;
pthread_mutex_t lock;
pthread_condattr_t ca;
pthread_mutexattr_t ma;

int done = 0;

void _sleep()
{
	struct timespec tv;

	clock_gettime(CLOCK_REALTIME,&tv);
	tv.tv_sec += 1;
	tv.tv_nsec = 0;

	(void) pthread_mutex_lock(&lock);
	(void) pthread_cond_timedwait(&cv, &lock, &tv);
	(void) pthread_mutex_unlock(&lock);
}

static void
intr(int signo)
{
	done++;
}


int main()
{
	struct sigaction act;

	pthread_condattr_init(&ca);
	pthread_mutexattr_init(&ma);
	pthread_mutex_init(&lock, &ma);
	pthread_cond_init(&cv, &ca);


	(void) sigemptyset(&act.sa_mask);
	act.sa_flags = 0;
	act.sa_handler = intr;

	(void) sigaction(SIGINT, &act, NULL);

	while(!done)
	{
		printf("enter\n");
		_sleep();
		printf("exit\n");
	}

	printf("done\n");
	return 0;
}


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-arm mailing list