blktrace segfault.
Core was generated by `blktrace -d /dev/hdc'. Program terminated with signal 11, Segmentation fault. #0 0xb7e4cdec in ?? ()
(gdb) where
#0 0xb7e4cdec in ?? () #1 0xb7dbf000 in ?? () #2 0x00021000 in ?? () #3 0xb7dee6e8 in ?? () #4 0x0804ecf0 in ?? () #5 0x00000001 in ?? () #6 0x6c616367 in ?? () #7 0xbfee3f68 in ?? () #8 0xb7f51300 in ?? () #9 0x00000168 in ?? ()
#10 0x0804ecf0 in ?? ()
#11 0x00000001 in ?? ()
#12 0xbfee3f88 in ?? ()
#13 0xbfee3f68 in ?? ()
#14 0x080499dc in close_thread (tip=0xb7f1eff4) at blktrace.c:637 Backtrace stopped: frame did not save the PC
(gdb)
the below diff fix the same.
blktrace.c +1 -0
@@ -1220,6 +1220,7 @@ static int start_devices(void) size = ncpus *sizeof (struct thread_information ); thread_information =malloc (size * ndevs); +memset (thread_information,0 , size*ndevs);if (!thread_information) {fprintf (stderr,"Out of memory, threads (%d)\n" , size * ndevs);return 1 ;
Jens Axboe
AppliedQuoted 23 lines · Aneesh Kumar K.V
Core was generated by `blktrace -d
/dev/hdc'. Program terminated with signal 11, Segmentation fault. #00xb7e4cdecin ?? ()
(gdb) where#0 0xb7e4cdec in ?? () #1 0xb7dbf000 in ?? () #2 0x00021000 in ?? () #3 0xb7dee6e8 in ?? () #4 0x0804ecf0 in ?? () #5 0x00000001 in ?? () #6 0x6c616367 in ?? () #7 0xbfee3f68 in ?? () #8 0xb7f51300 in ?? () #9 0x00000168 in ?? ()#10
0x0804ecf0in ?? ()
#110x00000001in ?? ()
#120xbfee3f88in ?? ()
#130xbfee3f68in ?? ()
#140x080499dcinclose_thread(tip=0xb7f1eff4) at blktrace.c:637 Backtrace stopped: frame did not save the PC
(gdb)
Quoted 1 line
the below diff fix the same.
Thanks, applied!
Signature · 1 line
Jens Axboe
Quoted 8 lines · Aneesh Kumar K.V
the below diff fix the same.
blktrace.c +0
-0
blktrace.c static int start_devices(void) · line 1225
Quoted 6 lines
blktrace.c +1
-0@@ -1220,6 +1220,7 @@ static int start_devices(void) size = ncpus *sizeof (struct thread_information ); thread_information =malloc (size * ndevs); +memset (thread_information,0 , size*ndevs);if (!thread_information) {fprintf (stderr,"Out of memory, threads (%d)\n" , size * ndevs);return 1 ;
I'm pretty sure you want to make the memset after the NULL-pointer check. If malloc fails this is segfaulting too.
Quoted 5 lines · Jan Blunck
Quoted 3 lines · Aneesh Kumar K.V
the below diff fix the same.
Quoted 14 lines
blktrace.c static int start_devices(void) · line 1225
Quoted 11 lines
blktrace.c +1
-0@@ -1220,6 +1220,7 @@ static int start_devices(void) size = ncpus *sizeof (struct thread_information ); thread_information =malloc (size * ndevs); +memset (thread_information,0 , size*ndevs);if (!thread_information) {fprintf (stderr,"Out of memory, threads (%d)\n" , size * ndevs);return 1 ;I'm pretty sure you want to make the memset after the NULL-pointer check. If malloc fails this is segfaulting too.
Ehm that's indeed a good point, I'll check in a fix for that.
Signature · 1 line
Jens Axboe
Quoted 11 lines · Jens Axboe
Quoted 9 lines
Quoted 6 lines
size = ncpus * sizeof(struct thread_information); thread_information = malloc(size * ndevs);blktrace.c +1
-0+memset (thread_information,0 , size*ndevs);if (!thread_information) { fprintf(stderr, "Out of memory, threads (%d)\n", size * ndevs); return 1;I'm pretty sure you want to make the memset after the NULL-pointer check. If malloc fails this is segfaulting too.
Ehm that's indeed a good point, I'll check in a fix for that.
Even better just use calloc..
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Jens Axboe
Quoted 9 lines
Quoted 6 lines
size = ncpus * sizeof(struct thread_information); thread_information = malloc(size * ndevs);blktrace.c +1
-0+memset (thread_information,0 , size*ndevs);if (!thread_information) { fprintf(stderr, "Out of memory, threads (%d)\n", size * ndevs); return 1;I'm pretty sure you want to make the memset after the NULL-pointer check. If malloc fails this is segfaulting too.
Quoted 3 lines
Quoted 1 line
Ehm that's indeed a good point, I'll check in a fix for that.
Even better just use calloc..
I considered it, but it holds ndevs * ncpus * size, so I thought it was cleaner to keep it as-is and just move the memset.
Signature · 1 line
Jens Axboe