[Sheepdog] Segmentation fault when getting obj information

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Apr 8 04:18:43 CEST 2010


Hi,

On Thu, Apr 8, 2010 at 12:33 AM, Wido den Hollander <wido at pcextreme.nl> wrote:
> Hi,
>
> I'm using the latest version (git revision) of Sheepdog, but when
> getting "obj" information, shepherd segfaults:
>
> root at wido-desktop:~# shepherd info -t obj Wido
> 457951fcbfc62f1
> 0, 27ca81e942cd0eef, 3207b6b8f585c0b6, 457951fcbfc62f1
> 1, 3207b6b8f585c0b6, 4f5de28d9ad07d49, 457951fcbfc62f1
> 2, 4f5de28d9ad07d49, d3d995c9a4f4336a, 457951fcbfc62f1
> Looking for the inode object 0x80fe96ac00000000 with 4 nodes
>
> Segmentation fault

Thanks for your report!
Can you try the following patch?


diff --git a/shepherd/shepherd.c b/shepherd/shepherd.c
index 1949f13..087c397 100644
--- a/shepherd/shepherd.c
+++ b/shepherd/shepherd.c
@@ -777,9 +777,15 @@ static void parse_objs(uint64_t oid, obj_parser_func_t func, void *data)
 {
 	char name[128];
 	int i, fd, ret;
+	char *buf;
+
+	buf = zalloc(sizeof(struct sheepdog_inode));
+	if (!buf) {
+		fprintf(stderr, "out of memory\n");
+		return;
+	}
 
 	for (i = 0; i < nr_nodes; i++) {
-		char buf[sizeof(struct sheepdog_inode)];
 		unsigned wlen = 0, rlen = sizeof(buf);
 		struct sd_obj_req hdr;
 		struct sd_obj_rsp *rsp = (struct sd_obj_rsp *)&hdr;
@@ -808,6 +814,8 @@ static void parse_objs(uint64_t oid, obj_parser_func_t func, void *data)
 		else
 			func(name, oid, rsp, buf, data);
 	}
+
+	free(buf);
 }
 
 static void print_obj(char *vdiname, unsigned index)



More information about the sheepdog mailing list