Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1:/tmp/cvs-serv17122
Modified Files: Tag: devel_0_37 m_obj.c makefile makefile.in Log Message: introduced a more portable method for checking of stack overflows
Index: m_obj.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_obj.c,v retrieving revision 1.1.1.3.2.1 retrieving revision 1.1.1.3.2.2 diff -C2 -d -r1.1.1.3.2.1 -r1.1.1.3.2.2 *** m_obj.c 16 Oct 2003 16:09:48 -0000 1.1.1.3.2.1 --- m_obj.c 16 Oct 2003 16:50:20 -0000 1.1.1.3.2.2 *************** *** 10,13 **** --- 10,17 ---- #include "m_imp.h"
+ /* T.Grill - define for a modified, more portable method to detect stack overflows */ + #define NEWSTACKMETH + + union inletunion { *************** *** 257,262 **** --- 261,272 ---- /* --------------------------- outlets ------------------------------ */
+ #ifdef NEWSTACKMETH + static int stackcount = 0; + #define STACKITER 1000 + #else static char *stacklimit, *topstack; #define STACKSIZE 1000000 + #endif + static int outlet_eventno;
*************** *** 264,272 **** --- 274,285 ---- for the outlet functions to check to prevent stack overflow from message recursion */ + void outlet_setstacklim(void) { + #ifndef NEWSTACKMETH char c; topstack = &c; stacklimit = (&c) - STACKSIZE; + #endif outlet_eventno++; } *************** *** 311,315 **** --- 324,330 ---- { pd_error(x->o_owner, "stack overflow"); + #ifndef NEWSTACKMETH stacklimit = topstack; + #endif }
*************** *** 317,328 **** { t_outconnect *oc; ! #ifndef NOSTACKCHK char c; if (&c < stacklimit) outlet_stackerror(x); else - #endif for (oc = x->o_connections; oc; oc = oc->oc_next) pd_bang(oc->oc_to); }
--- 332,348 ---- { t_outconnect *oc; ! #ifdef NEWSTACKMETH ! if(++stackcount >= STACKITER) ! #else char c; if (&c < stacklimit) + #endif outlet_stackerror(x); else for (oc = x->o_connections; oc; oc = oc->oc_next) pd_bang(oc->oc_to); + #ifdef NEWSTACKMETH + --stackcount; + #endif }
*************** *** 331,340 **** t_outconnect *oc; t_gpointer gpointer; ! #ifndef NOSTACKCHK ! char c; if (&c < stacklimit) outlet_stackerror(x); else - #endif { #if 0 --- 351,362 ---- t_outconnect *oc; t_gpointer gpointer; ! #ifdef NEWSTACKMETH ! if(++stackcount >= STACKITER) ! #else ! char c; if (&c < stacklimit) + #endif outlet_stackerror(x); else { #if 0 *************** *** 349,352 **** --- 371,377 ---- #endif } + #ifdef NEWSTACKMETH + --stackcount; + #endif }
*************** *** 354,365 **** { t_outconnect *oc; ! #ifndef NOSTACKCHK ! char c; if (&c < stacklimit) outlet_stackerror(x); ! else ! #endif for (oc = x->o_connections; oc; oc = oc->oc_next) pd_float(oc->oc_to, f); }
--- 379,395 ---- { t_outconnect *oc; ! #ifdef NEWSTACKMETH ! if(++stackcount >= STACKITER) ! #else ! char c; if (&c < stacklimit) + #endif outlet_stackerror(x); ! else for (oc = x->o_connections; oc; oc = oc->oc_next) pd_float(oc->oc_to, f); + #ifdef NEWSTACKMETH + --stackcount; + #endif }
*************** *** 367,378 **** { t_outconnect *oc; ! #ifndef NOSTACKCHK ! char c; if (&c < stacklimit) outlet_stackerror(x); ! else ! #endif for (oc = x->o_connections; oc; oc = oc->oc_next) pd_symbol(oc->oc_to, s); }
--- 397,413 ---- { t_outconnect *oc; ! #ifdef NEWSTACKMETH ! if(++stackcount >= STACKITER) ! #else ! char c; if (&c < stacklimit) + #endif outlet_stackerror(x); ! else for (oc = x->o_connections; oc; oc = oc->oc_next) pd_symbol(oc->oc_to, s); + #ifdef NEWSTACKMETH + --stackcount; + #endif }
*************** *** 380,391 **** { t_outconnect *oc; ! #ifndef NOSTACKCHK ! char c; if (&c < stacklimit) outlet_stackerror(x); ! else ! #endif for (oc = x->o_connections; oc; oc = oc->oc_next) pd_list(oc->oc_to, s, argc, argv); }
--- 415,431 ---- { t_outconnect *oc; ! #ifdef NEWSTACKMETH ! if(++stackcount >= STACKITER) ! #else ! char c; if (&c < stacklimit) + #endif outlet_stackerror(x); ! else for (oc = x->o_connections; oc; oc = oc->oc_next) pd_list(oc->oc_to, s, argc, argv); + #ifdef NEWSTACKMETH + --stackcount; + #endif }
*************** *** 393,404 **** { t_outconnect *oc; ! #ifndef NOSTACKCHK ! char c; if (&c < stacklimit) - outlet_stackerror(x); - else #endif for (oc = x->o_connections; oc; oc = oc->oc_next) typedmess(oc->oc_to, s, argc, argv); }
--- 433,449 ---- { t_outconnect *oc; ! #ifdef NEWSTACKMETH ! if(++stackcount >= STACKITER) ! #else ! char c; if (&c < stacklimit) #endif + outlet_stackerror(x); + else for (oc = x->o_connections; oc; oc = oc->oc_next) typedmess(oc->oc_to, s, argc, argv); + #ifdef NEWSTACKMETH + --stackcount; + #endif }
Index: makefile =================================================================== RCS file: /cvsroot/pure-data/pd/src/makefile,v retrieving revision 1.1.1.1.14.4 retrieving revision 1.1.1.1.14.5 diff -C2 -d -r1.1.1.1.14.4 -r1.1.1.1.14.5 *** makefile 15 Oct 2003 07:55:10 -0000 1.1.1.1.14.4 --- makefile 16 Oct 2003 16:50:20 -0000 1.1.1.1.14.5 *************** *** 11,15 **** MANDIR = ${prefix}/man
! MORECFLAGS = -DDL_OPEN -DPA_USE_OSS -DPA_LITTLE_ENDIAN -DUSEAPI_OSS -I../portaudio/pa_common -I../portaudio/pablio -I../portaudio/portmidi-macosx -DPA_USE_ALSA -DUSEAPI_ALSA -DUSEAPI_JACK
INCLUDE = -I. --- 11,15 ---- MANDIR = ${prefix}/man
! MORECFLAGS = -DDL_OPEN -DPA_USE_OSS -DPA_LITTLE_ENDIAN -DUSEAPI_OSS -I../portaudio/pa_common -I../portaudio/pablio -I../portaudio/portmidi-macosx -Werror -DPA_USE_ALSA -DUSEAPI_ALSA -DUSEAPI_JACK
INCLUDE = -I. *************** *** 20,29 **** LIB = -ldl -lm -lpthread -lasound
! OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer ! WARN_CFLAGS = -Wall -W -Wstrict-prototypes \ -Wno-unused -Wno-parentheses -Wno-switch ARCH_CFLAGS = -DPD -DUNIX
! CFLAGS = $(ARCH_CFLAGS) $(WARN_CFLAGS) $(OPT_CFLAGS) $(MORECFLAGS)
# the sources --- 20,29 ---- LIB = -ldl -lm -lpthread -lasound
! OPT_CFLAGS = -g ! WARN_CFLAGS = -Wall -W -Wstrict-prototypes -Werror \ -Wno-unused -Wno-parentheses -Wno-switch ARCH_CFLAGS = -DPD -DUNIX
! CFLAGS += $(ARCH_CFLAGS) $(WARN_CFLAGS) $(OPT_CFLAGS) $(MORECFLAGS)
# the sources *************** *** 79,89 ****
$(BIN_DIR)/pd-watchdog: s_watchdog.c ! cc -O2 $(STRIPFLAG) -o $(BIN_DIR)/pd-watchdog s_watchdog.c
$(BIN_DIR)/pdsend: u_pdsend.c ! cc $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdsend u_pdsend.c
$(BIN_DIR)/pdreceive: u_pdreceive.c ! cc $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdreceive u_pdreceive.c
$(PDEXEC): $(OBJ) --- 79,89 ----
$(BIN_DIR)/pd-watchdog: s_watchdog.c ! $(CC) -O2 $(STRIPFLAG) -o $(BIN_DIR)/pd-watchdog s_watchdog.c
$(BIN_DIR)/pdsend: u_pdsend.c ! $(CC) $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdsend u_pdsend.c
$(BIN_DIR)/pdreceive: u_pdreceive.c ! $(CC) $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdreceive u_pdreceive.c
$(PDEXEC): $(OBJ)
Index: makefile.in =================================================================== RCS file: /cvsroot/pure-data/pd/src/makefile.in,v retrieving revision 1.1.1.3.2.8 retrieving revision 1.1.1.3.2.9 diff -C2 -d -r1.1.1.3.2.8 -r1.1.1.3.2.9 *** makefile.in 12 Oct 2003 15:15:41 -0000 1.1.1.3.2.8 --- makefile.in 16 Oct 2003 16:50:20 -0000 1.1.1.3.2.9 *************** *** 25,29 **** ARCH_CFLAGS = -DPD -DUNIX
! CFLAGS = $(ARCH_CFLAGS) $(WARN_CFLAGS) $(OPT_CFLAGS) $(MORECFLAGS)
# the sources --- 25,29 ---- ARCH_CFLAGS = -DPD -DUNIX
! CFLAGS += $(ARCH_CFLAGS) $(WARN_CFLAGS) $(OPT_CFLAGS) $(MORECFLAGS)
# the sources *************** *** 79,89 ****
$(BIN_DIR)/pd-watchdog: s_watchdog.c ! cc -O2 $(STRIPFLAG) -o $(BIN_DIR)/pd-watchdog s_watchdog.c
$(BIN_DIR)/pdsend: u_pdsend.c ! cc $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdsend u_pdsend.c
$(BIN_DIR)/pdreceive: u_pdreceive.c ! cc $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdreceive u_pdreceive.c
$(PDEXEC): $(OBJ) --- 79,89 ----
$(BIN_DIR)/pd-watchdog: s_watchdog.c ! $(CC) -O2 $(STRIPFLAG) -o $(BIN_DIR)/pd-watchdog s_watchdog.c
$(BIN_DIR)/pdsend: u_pdsend.c ! $(CC) $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdsend u_pdsend.c
$(BIN_DIR)/pdreceive: u_pdreceive.c ! $(CC) $(CFLAGS) $(STRIPFLAG) -o $(BIN_DIR)/pdreceive u_pdreceive.c
$(PDEXEC): $(OBJ)