svn commit: r326150 - head/cddl/contrib/opensolaris/cmd/zdb

Andriy Gapon avg at FreeBSD.org
Fri Nov 24 10:45:34 UTC 2017


Author: avg
Date: Fri Nov 24 10:45:33 2017
New Revision: 326150
URL: https://svnweb.freebsd.org/changeset/base/326150

Log:
  zdb: use a heap allocation instead of a huge array on stack
  
  SPA_MAXBLOCKSIZE is 16 MB and having such a large object on the stack is
  not nice in general and it could cause some confusing failures in the
  single-user mode where the default stack size of 8 MB is used.
  
  I expect that the upstream would make the same change.
  
  MFC after:	1 week

Modified:
  head/cddl/contrib/opensolaris/cmd/zdb/zdb.c

Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Fri Nov 24 09:55:20 2017	(r326149)
+++ head/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Fri Nov 24 10:45:33 2017	(r326150)
@@ -3724,7 +3724,7 @@ zdb_embedded_block(char *thing)
 {
 	blkptr_t bp = { 0 };
 	unsigned long long *words = (void *)&bp;
-	char buf[SPA_MAXBLOCKSIZE];
+	char *buf;
 	int err;
 
 	err = sscanf(thing, "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx:"
@@ -3738,12 +3738,15 @@ zdb_embedded_block(char *thing)
 		exit(1);
 	}
 	ASSERT3U(BPE_GET_LSIZE(&bp), <=, SPA_MAXBLOCKSIZE);
+	buf = malloc(SPA_MAXBLOCKSIZE);
 	err = decode_embedded_bp(&bp, buf, BPE_GET_LSIZE(&bp));
 	if (err != 0) {
 		(void) printf("decode failed: %u\n", err);
+		free(buf);
 		exit(1);
 	}
 	zdb_dump_block_raw(buf, BPE_GET_LSIZE(&bp), 0);
+	free(buf);
 }
 
 static boolean_t


More information about the svn-src-all mailing list