google / brotli

Brotli compression format
MIT License
13.3k stars 1.22k forks source link

bus error on ARM CPUs (i.MX6) with GCC 12.3.0 #1159

Open ChHapp opened 2 months ago

ChHapp commented 2 months ago

I have experienced a 'bus-error' with Yocto-Mickledore (gcc 12.3.0) I am using the brotli lib with nodejs and when I run a simple compress/decompress example I get this 'bus-error'.

This is a generated example:

const zlib = require('zlib');
const inputString = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
const buffer = Buffer.from(inputString, 'utf-8');

// Compress the buffer using Brotli
zlib.brotliCompress(buffer, (err, compressedBuffer) => {
  if (err) {
    console.error('Error compressing data:', err);
    return;
  }

  // Convert compressed buffer to string
  const compressedString = compressedBuffer.toString('base64');  
  console.log('Compressed string:', compressedString);  
  // Decompress the compressed buffer to verify
  zlib.brotliDecompress(compressedBuffer, (err, decompressedBuffer) => {
    if (err) {
      console.error('Error decompressing data:', err);
      return;
    }    
    // Convert decompressed buffer back to string
    const decompressedString = decompressedBuffer.toString('utf-8');    
    console.log('Decompressed string:', decompressedString);
  });
});

I have figured out that if I add a bbappend with CFLAGS += " -Og" the 'libbrotlienc.so.1.0.9' works like a charm again. Alternatively if I compile it with the GCC 11.2.0 (Yocto-Honister) it also works as expected.

I have also tried newer TAGs and the Git HEAD too, with no luck to getting it to work by using '-O2' as a C flag.

Are there any recommended C flags for this project? Yocto is uses '-O2' by default. Is this a already known?