Wilfred / bfc

An industrial-grade brainfuck compiler
https://bfc.wilfred.me.uk
GNU General Public License v2.0
504 stars 30 forks source link

Mangled output of ANSI escape sequences in v1.11.0 and master branch #56

Open eliminmax opened 1 year ago

eliminmax commented 1 year ago

I am sorry that I can't think of a better way to put this, but bfc installed with cargo install --git (tested with both the master branch and tag 1.11.0) mangles the output of a program I wrote.

My program's output should be a mix of ANSI escape sequences and whitespace that look like the following: image

Instead, I get this:

image

Testing the same code with a different compiler (specifically ebfc from ELFkickers 3.2) and 2 interpreters (beef and one rather slow one I created myself and have not yet released publicly) have the expected output. Additionally, older versions of bfc work as expected. I installed version 1.10.0 with the command cargo install --git https://github.com/Wilfred/bfc.git --tag 1.10.0 and that worked properly.

In case it is helpful, the code for my colortest.bf program is here.

I have an asciinema recording comparing the output of bfc with the other compiler and interpreters which can be viewed here

eliminmax commented 1 year ago

Using git bisect, I was able to determine that the issue was introduced in commit 8709150, which is the one tagged 1.11.0. The commit before that one, c60c995, works properly.

Wilfred commented 1 year ago

Thanks for the great report and repros. :)

I've released 1.12 that reverts this bad optimisation, and I'll work out what's wrong with the optimisation and add a fixed version at some point in the future.

eliminmax commented 1 year ago

Just gave version 1.12.0 a try, and it is working perfectly. Thanks!

Wilfred commented 1 year ago

Glad to hear it! I'm going to leave this open so I can fix the optimisation with the repro given.