From: Brad N. <BNI...@no...> - 2009-11-30 16:53:49
|
>>> On 11/25/2009 at 11:12 AM, in message <75f...@ma...>, Sylvester Steele <syl...@gm...> wrote: >> I don't know why you would be getting a segfault on this line. Gmond > expects the array to be NULL terminated so all you are doing is adding one > extra entry and filling it will NULLs. With the array being NULL terminated, > gmond doesn't have to keep track of the metric count, it only has to look for > a NULL entry. >> > > > More modifications- and I can't figure out where the problem is. > > I tried > > gmi->name=NULL > > that didn't work either > > Then I thought I should remove the null metric and have only one metric > like: > > > > gmi = (Ganglia_25metric*)apr_array_push(metric_info); > > gmi->name= apr_pstrdup (pool,"Random_Numbers_2"); > gmi->tmax=90; > gmi->type=GANGLIA_VALUE_UNSIGNED_INT; > gmi->msg_size= UDP_HEADER_SIZE+8; > gmi->units= apr_pstrdup (pool,"Num"); > gmi->slope=apr_pstrdup (pool,"both"); > gmi->fmt=apr_pstrdup (pool,"%u"); > gmi->desc= apr_pstrdup (pool,"Example module metric (random numbers) 2"); > MMETRIC_INIT_METADATA(gmi, pool); > MMETRIC_ADD_METADATA(gmi,MGROUP,"example_2"); > > printf ("\n First metric done"); > > /* > gmi = (Ganglia_25metric*)apr_array_push(metric_info); > printf ("\nStarted second metric.."); > > gmi->name= apr_pstrdup (pool,"Constant_Number_2"); > gmi->tmax=90; > gmi->type=GANGLIA_VALUE_UNSIGNED_INT; > gmi->msg_size= UDP_HEADER_SIZE+8; > gmi->units= apr_pstrdup (pool,"Num"); > gmi->slope=apr_pstrdup (pool,"zero"); > gmi->fmt=apr_pstrdup (pool,"%u"); > gmi->desc= apr_pstrdup (pool,"Example module metric (constant number) 2"); > MMETRIC_INIT_METADATA(gmi, pool); > MMETRIC_ADD_METADATA(gmi,MGROUP,"example_2"); > > printf ("\nSecond metric done"); > */ > //gmi = (Ganglia_25metric*)apr_array_push(metric_info); > //printf ("\nStarted null metric"); > > //gmi->name= apr_pstrdup (pool,NULL); > > //memset (gmi, 0, sizeof(*gmi)); > printf ("\nMetric initing done"); > return 0; > > And this gives a segfault too! And here is the output: > > In the ex_metric_init function > Got first GMI > First metric done > Segmentation fault > > > ie there is a segfault between the last and second last printf > statements! Any clues? > Sorry, my only suggestion would be to run it in the debugger to get a better idea of what is happening. Brad |