Commit a9ccc340 authored by Daniel Barlow's avatar Daniel Barlow
Browse files

0.8.4.8

	More thread fixes: now passes the cl-ppcre thread test

	... all_threads_lock needed to be declared volatile

	... new 'state' field in struct thread, to avoid race where
	the head of the all_threads list is reaped during stop_for_gc

	Removed "waitpid : child %d %x exited \n" message (rather,
	conditionalised it on show_thread_exit, which is default 0

	Remove unexplained (setsigmask 0) call in the repl, replaced
	with a call to warn_when_signals_masked so we can find out
	what it was for anyway.

	Default repl calls (get-foreground) - this is a unithread nop
parent 7f029da2
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -23,8 +23,7 @@
  (signal sb!alien:int))

;;; Send the signal SIGNAL to the process with process id PID. SIGNAL
;;; should be a valid signal number or a keyword of the standard UNIX
;;; signal name.
;;; should be a valid signal number
(defun unix-kill (pid signal)
  (real-unix-kill pid signal))

@@ -34,8 +33,7 @@
  (signal sb!alien:int))

;;; Send the signal SIGNAL to the all the process in process group
;;; PGRP. SIGNAL should be a valid signal number or a keyword of the
;;; standard UNIX signal name.
;;; PGRP. SIGNAL should be a valid signal number
(defun unix-killpg (pgrp signal)
  (real-unix-killpg pgrp signal))

@@ -57,7 +55,13 @@
			       sb!alien:unsigned-long
  (signal sb!alien:int)
  (handler sb!alien:unsigned-long))
;;; assert (though non-fatally) that there are no signals masked
(sb!alien:define-alien-routine "warn_when_signals_masked" sb!alien:void)





;;;; interface to enabling and disabling signal handlers

(defun enable-interrupt (signal handler)
+2 −1
Original line number Diff line number Diff line
@@ -510,7 +510,7 @@
	   (abort
	    "~@<Reduce debugger level (leaving debugger, returning to toplevel).~@:>")
	 (catch 'toplevel-catcher
	   #!-sunos (sb!unix:unix-sigsetmask 0)	; FIXME: What is this for?
	   (sb!unix::warn-when-signals-masked)
	   ;; in the event of a control-stack-exhausted-error, we should
	   ;; have unwound enough stack by the time we get here that this
	   ;; is now possible
@@ -553,6 +553,7 @@
  (loop
   ;; (See comment preceding the definition of SCRUB-CONTROL-STACK.)
   (scrub-control-stack)
   (sb!thread::get-foreground)
   (unless noprint
     (funcall *repl-prompt-fun* *standard-output*)
     ;; (Should *REPL-PROMPT-FUN* be responsible for doing its own
+1 −0
Original line number Diff line number Diff line
@@ -384,6 +384,7 @@
  (tls-cookie)				;  on x86, the LDT index 
  (this :c-type "struct thread *" :length #!+alpha 2 #!-alpha 1)
  (next :c-type "struct thread *" :length #!+alpha 2 #!-alpha 1)
  (state)				; running, stopping, stopped
  #!+x86 (pseudo-atomic-atomic)
  #!+x86 (pseudo-atomic-interrupted)
  (interrupt-data :c-type "struct interrupt_data *" 
+28 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ static void store_signal_data_for_later (struct interrupt_data *data,
					 os_context_t *context);
boolean interrupt_maybe_gc_int(int signal, siginfo_t *info, void *v_context);

extern lispobj all_threads_lock;
extern volatile lispobj all_threads_lock;
extern volatile int countdown_to_gc;

/*
@@ -117,6 +117,32 @@ boolean internal_errors_enabled = 0;

struct interrupt_data * global_interrupt_data;

/* this is used from Lisp in toplevel.lisp, replacing an older 
 * (sigsetmask 0) - we'd like to find out when the signal mask is 
 * not 0 */

/* This check was introduced in 0.8.4.x and some day will go away
 * again unless we find a way to trigger it */

void warn_when_signals_masked () 
{
    /* and as a side-eeffect, unmask them */
    sigset_t new,old;
    int i;
    int wrong=0;
    sigemptyset(&new);
    sigprocmask(SIG_SETMASK,&new,&old);
    for(i=1; i<NSIG; i++) {
	if(sigismember(&old,i)) {
	    fprintf(stderr,
		    "Warning: signal %d is masked: this is unexpected\n",i);
	    wrong=1;
	}
    }
    if(wrong) 
	fprintf(stderr,"If this version of SBCL is less than three months old, please report this.\nOtherwise, please try a newer version first\n.  Reset signal mask.\n");
}


/*
 * utility routines used by various signal handlers
@@ -518,6 +544,7 @@ sig_stop_for_gc_handler(int signal, siginfo_t *info, void *void_context)

    get_spinlock(&all_threads_lock,thread->pid);
    countdown_to_gc--;
    thread->state=STATE_STOPPED;
    release_spinlock(&all_threads_lock);
    kill(thread->pid,SIGSTOP);

+3 −1
Original line number Diff line number Diff line
@@ -379,6 +379,7 @@ static void parent_sighandler(int signum,siginfo_t *info, void *void_context)
}

#ifdef LISP_FEATURE_SB_THREAD
int show_thread_exit=0;

static void /* noreturn */ parent_loop(void)
{
@@ -421,6 +422,7 @@ static void /* noreturn */ parent_loop(void)
	if(WIFEXITED(status) || WIFSIGNALED(status)) {
	    th=find_thread_by_pid(pid);
	    if(!th) continue;
	    if(show_thread_exit)
		fprintf(stderr,"waitpid : child %d %x exited \n", pid,th);
	    destroy_thread(th);
	    if(!all_threads) break;
Loading