Bug#921146: Bug#923711: squashfs-tools: Please apply frag_deflator_thread removal patch

2019-03-25 Thread Alexander Couzens
> Laszlo, would you like any assistance with a debdiff or is lynxis'
> patch sufficient asis? You will have to patch the existing patch, if
> you see what I mean...

Here is an updated patch to match debian's state of squashfs-tools.

Best,
lynxis
Index: squashfs-tools-4.3/squashfs-tools/mksquashfs.c
===
--- squashfs-tools-4.3.orig/squashfs-tools/mksquashfs.c
+++ squashfs-tools-4.3/squashfs-tools/mksquashfs.c
@@ -2426,16 +2426,21 @@ void *deflator(void *arg)
 void frag_deflator(struct file_buffer *file_buffer)
 {
 	int res;
+	int c_byte, compressed_size;
+	struct file_buffer *write_buffer;
 
-	res = compressor_init(comp, , block_size, 1);
-	if(res)
-		BAD_ERROR("frag_deflator:: compressor_init failed\n");
+	static int frag_deflator_comp_init = FALSE;
+	static void *frag_stream = NULL;
 
-	int c_byte, compressed_size;
-	struct file_buffer *write_buffer =
-			cache_get(fwriter_buffer, file_buffer->block);
+	if (frag_deflator_comp_init == FALSE) {
+		frag_deflator_comp_init = TRUE;
+		res = compressor_init(comp, _stream, block_size, 1);
+		if(res)
+			BAD_ERROR("frag_deflator:: compressor_init failed\n");
+	}
 
-	c_byte = mangle2(stream, write_buffer->data, file_buffer->data,
+	write_buffer = cache_get(fwriter_buffer, file_buffer->block);
+	c_byte = mangle2(frag_stream, write_buffer->data, file_buffer->data,
 			 file_buffer->size, block_size, noF, 1);
 	compressed_size = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
 	write_buffer->size = compressed_size;


pgpJzIqWVDpMd.pgp
Description: OpenPGP digital signature


Bug#921146: Bug#923711: squashfs-tools: Please apply frag_deflator_thread removal patch

2019-03-25 Thread Alexander Couzens
Hi lamby,

> Alas, I don't think I will be able to get to writing a patch/fix today
> as I don't fully understand the leak (or, actually, the original
> patch!) just yet.
> 
> Lynxis, do you have any quick pointers, however?

original, my patch had the problem, that it use the 
same stream (compressor context) as the main thread. This seems to be
ok, as long the compression is not lzo (I tested with lzma).

After your patch to fix lzo, the compressor will be initialized with a
new context on every fragment instead only once for all fragments.
Also important, all compressor_init's will leak, but since they are
only called once, it's not a big problem to leak some kbs.

I attached a patch to fix this to the bug #923711
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923711
It would be nice if you can test it.

Best,
lynxis

PS: If you like to write a small test script, I'm happy to add it to the
CI ;)


pgpdHlvFNaRuL.pgp
Description: OpenPGP digital signature