The xbl-1.1.2 source uses the 0 (32-bit) constant where a NULL reference should be used. On my amd64 this produces a segfault on startup after va_arg returns a 0 constant and this is placed in a 64 bit register, apparently leaving the higher 32 bits untouched. Reproducible: Always Steps to Reproduce: 1. Emerge xblockout-1.1.2 on a amd64 platform 2. Run it Actual Results: segfault
Created attachment 72310 [details, diff] patch to fix the crashes. Also sent this to the xblockout author. After linting the source I replaced all the 0s which would be cast to null references to NULL.
Comment on attachment 72310 [details, diff] patch to fix the crashes. Also sent this to the xblockout author. diff -ur xbl-1.1.2/bl.c xbl-1.1.2-amd64fix/bl.c --- xbl-1.1.2/bl.c 2003-08-31 21:59:38.000000000 +0200 +++ xbl-1.1.2-amd64fix/bl.c 2005-11-06 16:17:56.000000000 +0100 @@ -229,7 +229,7 @@ int buffering ; char *value ; - bl.x.display = 0 ; + bl.x.display = NULL ; signal(SIGINT,quitprog) ; signal(SIGQUIT,quitprog) ; @@ -443,7 +443,7 @@ void speedtest(struct bl *blo) { - time_t starttime,currenttime ; + clock_t starttime,currenttime ; int i ; XEvent event ; @@ -470,20 +470,21 @@ (void)addtransfo( RZP,100,&blo->bloc,10000) ; (void)addtransfo( RYP,200,&blo->bloc,20000) ; inittime(&blo->realtime,1) ; - time( &starttime ) ; + starttime = clock(); - for(i=0;i<1000;i++) + for(i=0;i<10000;i++) { displaymoving(&blo->opt,&blo->x,&blo->bloc,&blo->draw) ; (void)nextime( &blo->bloc ) ; XSync(blo->x.display,False) ; } - time( ¤ttime ) ; + currenttime = clock() ; - printf("%3ld frames/sec buffering=%d %s clearline=%d\n", - i/(currenttime-starttime), + double fps = (i * CLOCKS_PER_SEC) / (currenttime - starttime); + printf("%.2f frames/sec buffering=%d %s clearline=%d\n", + fps, blo->opt.buffering, - blo->opt.drawmode==0? "Wireframe":"FaceDrawing", + (blo->opt.drawmode == 0 ? "Wireframe":"FaceDrawing"), blo->opt.clearline ); quitprog(0) ; diff -ur xbl-1.1.2/bloc.c xbl-1.1.2-amd64fix/bloc.c --- xbl-1.1.2/bloc.c 2003-06-29 15:27:33.000000000 +0200 +++ xbl-1.1.2-amd64fix/bloc.c 2005-11-06 15:13:36.000000000 +0100 @@ -57,7 +57,7 @@ } ; /* Contain last draw line bloc */ -static struct polypolyline lastlinebloc = {0,0,0} ; +static struct polypolyline lastlinebloc = {0,0, NULL} ; /* Definition of a bloc : a string @@ -143,7 +143,7 @@ nbtmp = 0 ; tmp = (struct edge*) malloc( b->nbedges*sizeof(*tmp) ) ; - start = end = 0 ; /* Only to remove a GCC warning */ + start = end = NULL ; /* Only to remove a GCC warning */ /* First stage : concatenate lines */ for(i=0;i<b->nbedges;i++) @@ -264,7 +264,7 @@ void createfaces(struct bloc *b) { int i,j,k,l ; - if ( b->face==0 ) + if ( b->face==NULL ) b->face = (struct face*) malloc( 6*b->dx*b->dy*b->dz*sizeof(struct face) ) ; b->nbfaces = 0 ; @@ -277,21 +277,21 @@ switch(l) { case 2 : - if ( k==0 || b->t[k-1][j][i]==0 ) + if ( k==0 || b->t[k-1][j][i]=='\0' ) noteface(b,i,j,k,i+1,j,k,i+1,j+1,k,i,j+1,k ,k) ; break ; case 1 : - if ( i==0 || b->t[k][j][i-1]==0 ) + if ( i==0 || b->t[k][j][i-1]=='\0' ) noteface(b,i,j,k,i,j+1,k,i,j+1,k+1,i,j,k+1 ,k) ; - if ( j==0 || b->t[k][j-1][i]==0 ) + if ( j==0 || b->t[k][j-1][i]=='\0' ) noteface(b,i,j,k,i,j,k+1,i+1,j,k+1,i+1,j,k ,k) ; - if ( i==b->dx-1 || b->t[k][j][i+1]==0 ) + if ( i==b->dx-1 || b->t[k][j][i+1]=='\0' ) noteface(b,i+1,j,k,i+1,j,k+1,i+1,j+1,k+1,i+1,j+1,k ,k) ; - if ( j==b->dy-1 || b->t[k][j+1][i]==0 ) + if ( j==b->dy-1 || b->t[k][j+1][i]=='\0' ) noteface(b,i,j+1,k,i+1,j+1,k,i+1,j+1,k+1,i,j+1,k+1 ,k) ; break ; case 0 : - if ( k==b->dz-1 || b->t[k+1][j][i]==0 ) + if ( k==b->dz-1 || b->t[k+1][j][i]=='\0' ) noteface(b,i,j,k+1,i,j+1,k+1,i+1,j+1,k+1,i+1,j,k+1 ,k) ; break ; } @@ -314,7 +314,7 @@ e = e->next ; } - if ( e==0 ) + if ( e == NULL ) { b->edge[b->nbedges].start = start ; b->edge[b->nbedges].end = end ; @@ -340,7 +340,7 @@ b->point[i].coord[1] = y ; b->point[i].coord[2] = z ; b->point[i].next = b->firstpoint ; - b->point[i].edge = 0 ; + b->point[i].edge = NULL ; b->point[i].in_a_bloc = 1 ; b->firstpoint = &b->point[i] ; } @@ -366,15 +366,15 @@ b->nbpoints = (b->dz+1)*(b->dy+1)*(b->dx+1) ; b->point = (struct point*) malloc( b->nbpoints*sizeof(struct point) ) ; - b->face = 0 ; - b->segments = 0 ; + b->face = NULL ; + b->segments = NULL ; for(i=0;i<b->nbpoints;i++) { - b->point[i].next = 0 ; - b->point[i].edge = 0 ; + b->point[i].next = NULL ; + b->point[i].edge = NULL ; b->point[i].in_a_bloc = 0 ; } - b->firstpoint = 0 ; + b->firstpoint = NULL ; b->t = (char***) malloc( b->dz*sizeof(char **) ) ; pc = (char*) malloc( (unsigned)(b->dz*b->dy*b->dx) ) ; @@ -548,7 +548,7 @@ void clearlastline(Display *disp, Drawable d, GC gc) { - static struct polypolyline memo = {0,0,0} ; + static struct polypolyline memo = {0,0,NULL} ; drawpolypolyline(disp,d,gc,&memo) ; copypolypolyline(&memo,&lastlinebloc) ; } diff -ur xbl-1.1.2/demo.c xbl-1.1.2-amd64fix/demo.c --- xbl-1.1.2/demo.c 2003-06-29 15:41:49.000000000 +0200 +++ xbl-1.1.2-amd64fix/demo.c 2005-11-06 15:13:36.000000000 +0100 @@ -40,7 +40,7 @@ /***********************************************************************/ -static struct bloc *w=0 ; +static struct bloc *w= NULL ; void save_world(struct bloc *b) { diff -ur xbl-1.1.2/draw.c xbl-1.1.2-amd64fix/draw.c --- xbl-1.1.2/draw.c 2003-06-29 15:43:17.000000000 +0200 +++ xbl-1.1.2-amd64fix/draw.c 2005-11-06 14:37:23.000000000 +0100 @@ -450,9 +450,9 @@ if ( opt->presskey==0 && (opt->state==STOP || opt->state==SUSPEND) ) { - static GC blac=0,whit=0 ; + static GC blac = NULL,whit = NULL ; - if ( blac==0 ) + if ( blac == NULL ) { XGCValues xgc ; blac = XCreateGC(x->display,x->window,(unsigned long)0,&xgc) ; diff -ur xbl-1.1.2/gameevent.c xbl-1.1.2-amd64fix/gameevent.c --- xbl-1.1.2/gameevent.c 2003-07-02 21:40:23.000000000 +0200 +++ xbl-1.1.2-amd64fix/gameevent.c 2005-11-06 14:50:03.000000000 +0100 @@ -88,7 +88,7 @@ fprintf(stderr,"Keypad or cursor event : %c\n",buf[0]) ; } else - nb = XLookupString((XKeyEvent*)e,buf,256,0,0); + nb = XLookupString((XKeyEvent*)e,buf,256,NULL,NULL); if ( bl->opt.verbose ) { diff -ur xbl-1.1.2/help.c xbl-1.1.2-amd64fix/help.c --- xbl-1.1.2/help.c 2003-06-29 15:45:17.000000000 +0200 +++ xbl-1.1.2-amd64fix/help.c 2005-11-06 15:13:36.000000000 +0100 @@ -224,7 +224,7 @@ l = (dx+7)/8 ; xx = dx ; yy = dy ; - for(i=0;i<m;i++) e[i] = 0 ; + for(i=0;i<m;i++) e[i] = NULL ; cube(dx,dy,tx,ty) ; return((char*)e) ; } diff -ur xbl-1.1.2/initmenu.c xbl-1.1.2-amd64fix/initmenu.c --- xbl-1.1.2/initmenu.c 2005-11-06 14:08:57.000000000 +0100 +++ xbl-1.1.2-amd64fix/initmenu.c 2005-11-06 14:35:00.000000000 +0100 @@ -64,36 +64,36 @@ init_movinggc(d,w,&movinggc,bl->x.back_pixel,bl->x.white_pixel,bl->x.black_pixe l) ; - m->score = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())0,textthescore, + m->score = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)()) NULL,textthescore, create_line("Score",m->xfont,m->text1), create_line("000000",m->xfont2,m->text2), - 0) ; - m->hiscore = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())0,texthiscore, + NULL) ; + m->hiscore = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())NULL,texthiscore, create_line("High Score",m->xfont,m->text1), create_line("000000",m->xfont2,m->text2), - 0) ; - m->cube = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())0,textcube, + NULL) ; + m->cube = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())NULL,textcube, create_line("#cubes 00000",m->xfont,m->text1), - 0) ; - m->bloc = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())0,textbloc, + NULL) ; + m->bloc = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())NULL,textbloc, create_line("#blocs 00000",m->xfont,m->text1), - 0) ; - m->destroylevel = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())0,textdlevel, + NULL) ; + m->destroylevel = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())NULL,textdlevel, create_line("#destroy level",m->xfont,m->text1), create_line("0000",m->xfont,m->text1), - 0) ; - m->level = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())0,textlevel, + NULL) ; + m->level = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())NULL,textlevel, create_line("current level",m->xfont,m->text1), create_line("00",m->xfont,m->text1), - 0) ; + NULL) ; m->nextpiece = create_button(CSTP,RELIEF_TEXT,&movinggc,fctnextpiece,textnextpiece, create_line("Click me",m->xfont,m->text1), create_line("to see",m->xfont,m->text1), create_line("next piece",m->xfont,m->text1), - 0) ; + NULL) ; col1 = scotch((struct row_column*)m->score, m->hiscore, m->cube, m->bloc, m->destroylevel, - m->level, m->nextpiece, 0 ) ; + m->level, m->nextpiece, NULL ) ; m->score->menu = m ; m->hiscore->menu = m ; m->cube->menu = m ; @@ -104,44 +104,44 @@ m->land = create_button(CSTP,RELIEF_TEXT,&movinggc,fctland,textland, create_line(SMALL_LAND,m->xfont,m->text1), - 0) ; + NULL) ; m->typepiece=create_button(CSTP,RELIEF_TEXT,&movinggc,fcttype,texttype, create_line(COMPLEX_PIECE,m->xfont,m->text1), - 0) ; + NULL) ; m->width = create_button(CSTP,RELIEF_TEXT,&movinggc,fctwidth,textwidth, create_line("Width 00",m->xfont,m->text1), - 0) ; + NULL) ; m->height = create_button(CSTP,RELIEF_TEXT,&movinggc,fctheight,textheight, create_line("Height 00",m->xfont,m->text1), - 0) ; + NULL) ; m->depth = create_button(CSTP,RELIEF_TEXT,&movinggc,fctdepth,textdepth, create_line("Depth 00",m->xfont,m->text1), - 0) ; + NULL) ; m->startlevel=create_button(CSTP,RELIEF_TEXT,&movinggc,fctlevel,textstartlevel, create_line("Start level 00",m->xfont,m->text1), - 0) ; + NULL) ; m->training = create_button(CSTP,RELIEF_TEXT,&movinggc,fcttraining,texttraining, create_line(NORMAL_PLAY,m->xfont,m->text1), - 0) ; + NULL) ; m->volume = create_button(CSTP,RELIEF_TEXT,&movinggc,fctvolume,textvolume, create_line("Sound volume 00",m->xfont,m->text1), - 0) ; + NULL) ; m->viewzoo = create_button(CSTP,RELIEF_TEXT,&movinggc,fctzoo,textzoo, create_line(SHOW_ZOO,m->xfont,m->text1), - 0) ; + NULL) ; m->viewscore=create_button(CSTP,RELIEF_TEXT,&movinggc,fctscore,textscore, create_line(SHOW_SCORE,m->xfont,m->text1), - 0) ; + NULL) ; m->stereo = create_button(CSTP,RELIEF_TEXT,&movinggc,fctstereo,textstereo, create_line("Eye Distance 9.9",m->xfont,m->text1), - 0) ; - m->frame=create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())0,textframe, + NULL) ; + m->frame=create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())NULL,textframe, create_line("Frame/Sec. 000",m->xfont,m->text1), - 0) ; + NULL) ; col2 = scotch((struct row_column*)m->land, m->width,m->height,m->depth,m->typepiece, m->startlevel, m->training, - m->viewzoo,m->viewscore,m->stereo, 0 ) ; + m->viewzoo,m->viewscore,m->stereo, NULL ) ; m->land->menu = m ; m->typepiece->menu = m ; m->width->menu = m ; @@ -157,10 +157,10 @@ m->smooth = create_button(CSTP,RELIEF_TEXT,&movinggc,fctsmooth,textsmooth, create_line(SMOOTH_DRAW,m->xfont,m->text1), - 0) ; + NULL) ; m->draw = create_button(CSTP,RELIEF_TEXT,&movinggc,fctdraw,textdraw, create_line(TRANSP_DRAW,m->xfont,m->text1), - 0) ; + NULL) ; m->key = create_button(CSTP,RELIEF_TEXT,&movinggc,fctkey,textkey, create_line("QWERTY -",m->xfont,m->text1), create_line("^X DownLeft ^X Cancel-",m->xfont,m->text1), @@ -174,19 +174,19 @@ create_line("^X DownLeft ^X Cancel-",m->xfont,m->text1), create_line("^X DownLeft ^X Cancel-",m->xfont,m->text1), create_line("^X DownLeft ^X Cancel-",m->xfont,m->text1), - 0) ; + NULL) ; createhelp(m->key,bl->key) ; - m->quit = create_button(CSTP,RELIEF_TEXT,&movinggc,fctquit,(void(*)())0, + m->quit = create_button(CSTP,RELIEF_TEXT,&movinggc,fctquit,(void(*)())NULL, create_line("QUIT",m->xfont,m->text1), - 0) ; - m->state = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())0,textstate, + NULL) ; + m->state = create_button(CSTP,FLAT_TEXT,&movinggc,(void(*)())NULL,textstate, create_line(SUSPENDED_GAME,m->xfont,m->text1), - 0) ; + NULL) ; col3 = scotch((struct row_column*)m->key,m->volume,m->smooth, m->draw, - scotch(scotch((struct row_column*)m->state,m->frame,0), m->quit, 0 ), - 0 ) ; + scotch(scotch((struct row_column*)m->state,m->frame, NULL), m->quit, NULL ), + NULL ) ; m->smooth->menu = m ; m->draw->menu = m ; m->key->menu = m ; @@ -194,22 +194,22 @@ m->quit->menu = m ; m->state->menu = m ; - m->copyright = create_button(CSTP,RELIEF_TEXT,&movinggc,fctcopyright,(void(*)())0, + m->copyright = create_button(CSTP,RELIEF_TEXT,&movinggc,fctcopyright,(void(*)())NULL, create_line("Copyright (C) 1992-1994,2001,2003 Thierry EXCOFFIER",m->xfont,m->text1), create_line("XBlockOut comes with ABSOLUTELY NO WARRANTY, This is",m->xfont,m->text1), create_line("free software, and you are welcome to redistribute it",m->xfont,m->text1), create_line("under certain conditions; Click here for more detail.",m->xfont,m->text1), - 0) ; + NULL) ; if ( 0 ) { m->all = scotch( - scotch((struct row_column*)col1,col2,col3,0 ), + scotch((struct row_column*)col1,col2,col3, NULL ), m->copyright, - 0 + NULL ) ; } else - m->all = scotch((struct row_column*)col1,col2,col3,0 ) ; + m->all = scotch((struct row_column*)col1,col2,col3, NULL ) ; m->copyright->menu = m ; @@ -297,7 +297,7 @@ XSetStandardProperties(x->display,m->zoo,buf, "Zoo", x->icone, - (char**)0,0, + (char**)NULL,0, NULL ) ; /* The zoo ration must not be changed (not beautiful) */ @@ -356,7 +356,7 @@ XSetStandardProperties(x->display,m->window,buf, "Menu", x->icone, - (char**)0,0, + (char**)NULL,0, NULL ) ; /* Not interesting to increase window menu size */ diff -ur xbl-1.1.2/loop.c xbl-1.1.2-amd64fix/loop.c --- xbl-1.1.2/loop.c 2003-07-16 14:57:05.000000000 +0200 +++ xbl-1.1.2-amd64fix/loop.c 2005-11-06 14:39:51.000000000 +0100 @@ -234,7 +234,7 @@ b = bl->bloc.world ; b->nbedges = 0 ; - for(i=0;i<b->nbpoints;i++) b->point[i].edge = 0 ; + for(i=0;i<b->nbpoints;i++) b->point[i].edge = NULL ; for(i=0;i<=b->dx;i++) { diff -ur xbl-1.1.2/movingbutton.c xbl-1.1.2-amd64fix/movingbutton.c --- xbl-1.1.2/movingbutton.c 2005-11-06 14:10:53.000000000 +0100 +++ xbl-1.1.2-amd64fix/movingbutton.c 2005-11-06 14:42:02.000000000 +0100 @@ -412,7 +412,7 @@ va_start(b, cur) ; - if ( cur==0 ) + if ( cur==NULL ) { fprintf(stderr,"You must have something to scotch %s:%d\n", __FILE__,__LINE__) ; @@ -421,14 +421,14 @@ type = cur->type ; if ( type==A_COLUMN ) newtype = A_LINE ; else newtype = A_COLUMN ; - last = 0 ; - first = 0 ; /* Only to remove a GCC warning */ + last = NULL ; + first = NULL ; /* Only to remove a GCC warning */ do { newone = (struct row_column *) malloc( sizeof(*newone) ) ; newone->type = newtype ; newone->in = cur ; - newone->next = 0 ; + newone->next = NULL ; if ( last ) last->next = newone ; else first = newone ; last = newone ; @@ -589,9 +589,9 @@ /* Compute the minimum height */ int compute_height(struct row_column *r) { - (void)minimumheight((struct moving_button*)0,INIT_MINIMUM) ; + (void)minimumheight((struct moving_button*)NULL,INIT_MINIMUM) ; walkrowcol(r, (void (*)())minimumheight,COMPUTE_MINIMUM,0,0,0) ; - return( minimumheight((struct moving_button*)0,GIVE_MINIMUM) ) ; + return( minimumheight((struct moving_button*)NULL,GIVE_MINIMUM) ) ; } /* Stretch to minimum height or 2* 3* ... minimum height */ void compute_stretch(struct row_column *r, int minimum) Only in xbl-1.1.2: movingbutton.c~ diff -ur xbl-1.1.2/opbloc.c xbl-1.1.2-amd64fix/opbloc.c --- xbl-1.1.2/opbloc.c 2003-06-29 16:01:12.000000000 +0200 +++ xbl-1.1.2-amd64fix/opbloc.c 2005-11-06 14:58:48.000000000 +0100 @@ -110,11 +110,11 @@ do { p->in_a_bloc = 0 ; tmp = p->next ; - p->next = 0 ; - p->edge = 0 ; + p->next = NULL ; + p->edge = NULL ; p = tmp ; } while(p) ; - b->firstpoint = 0 ; + b->firstpoint = NULL ; return( nb+1 ) ; /* Number of destroy level */ } diff -ur xbl-1.1.2/options.c xbl-1.1.2-amd64fix/options.c --- xbl-1.1.2/options.c 2003-07-09 21:15:53.000000000 +0200 +++ xbl-1.1.2-amd64fix/options.c 2005-11-06 15:13:33.000000000 +0100 @@ -385,7 +385,7 @@ case '\0' : while ( *s==' ' || *s=='\t' ) s++ ; if ( *s!='\0' ) s-- ; - *pc++ = 0 ; + *pc++ = '\0' ; argv[++i] = pc ; if ( i>=NB_MAX_ARGS ) {
Appears to have been fixed by upstream in xblockout-1.1.3 (mentioned in changelog on 1.1.3 html manual file - already in portage)
Cool... fixed in 1.1.3