csmith-project / creduce

C-Reduce, a C and C++ program reducer
Other
1.31k stars 123 forks source link

pass_line_markers causes fatal error when reducing #195

Open arichardson opened 5 years ago

arichardson commented 5 years ago

After updating creduce I am no longer able to reduce clang crashes. Every time I try, creduce dies with the following stack trace:

Died at /usr/local/Cellar/creduce/2.10.0/share/creduce/perl/pass_line_markers.pm line 26.
 at /usr/local/Cellar/creduce/2.10.0/libexec/creduce line 35.
        main::__ANON__('Died at /usr/local/Cellar/creduce/2.10.0/share/creduce/perl/p...') called at /usr/local/Cellar/creduce/2.10.0/share/creduce/perl/pass_line_markers.pm line 26
        pass_line_markers::count_line_markers('usbdump-facd48-pp-smaller-reduce.c', 0) called at /usr/local/Cellar/creduce/2.10.0/share/creduce/perl/pass_line_markers.pm line 40
        pass_line_markers::new('usbdump-facd48-pp-smaller-reduce.c', 0) called at /usr/local/Cellar/creduce/2.10.0/libexec/creduce line 372
        main::call_new('pass_line_markers', 'usbdump-facd48-pp-smaller-reduce.c', 0) called at /usr/local/Cellar/creduce/2.10.0/libexec/creduce line 609
        main::delta_pass('HASH(0x7fc52886ad60)') called at /usr/local/Cellar/creduce/2.10.0/libexec/creduce line 1079
arichardson commented 5 years ago

Locally I've worked around this by deleting the following line: https://github.com/csmith-project/creduce/blob/8a67e69c49ef123a1c0a4898ac259249411a01dd/creduce/creduce.in#L762

Is there a way to work around this bug by passing command line flags? I often run creduce on a server where I can't build it from source or update packages.

regehr commented 5 years ago

I can add a command line option to remove a pass from the pass schedule, but I'd like to understand what leads to this assert being triggered, perhaps you can share a way for us to reproduce this problem? the line in question just opens the file being reduced, I don't see how this would fail.

arichardson commented 5 years ago

It appears that this pass is attempting to open the file in the current working directory but I invoke creduce with the CWD set to a different directory. In the example above my creduce wrapper uses ['time', '/usr/bin/creduce', '/tmp/tmpymnudx8l/reduce_script.sh', '/tmp/usbdump-facd48-pp-smaller-reduce.c', '--timing'] {'cwd': '/tmp/tmpymnudx8l'}

I just found a workaround: if I copy the input file to that directory before invoking creduce the pass will succeed.

It seems like the pass is opening the file before creduce has copied the current input to the working directory?

regehr commented 5 years ago

the rule for interestingness tests is that:

arichardson commented 5 years ago

I think the following is happening:

pass_line_markers opens the file in sub new ($$) which is called by https://github.com/csmith-project/creduce/blob/8a67e69c49ef123a1c0a4898ac259249411a01dd/creduce/creduce.in#L609. All other passes seem to open the $cfilevariable inside transform. It seems to me like c-reduce only copies the source file after calling new: https://github.com/csmith-project/creduce/blob/8a67e69c49ef123a1c0a4898ac259249411a01dd/creduce/creduce.in#L631 which is before calling transform: https://github.com/csmith-project/creduce/blob/8a67e69c49ef123a1c0a4898ac259249411a01dd/creduce/creduce.in#L635

Maybe pass_line_markers can be changed to open the file later?

Absoler commented 1 year ago

I found this too. It seems still not fixed. I have to put reduce target the same directory I invoke creduce, or use the option --skip-initial-passes