facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.13k stars 2.99k forks source link

hhbc regression: symlinks lead to duplicate definitions #8719

Open fredemmott opened 4 years ago

fredemmott commented 4 years ago

Describe the bug

Symlinks between hack files lead to "More than one with the name "

Standalone code, or other way to reproduce the problem

$ cd $(mktemp -d)
$ cd src
$ echo "function foo(): void {}" > foo.hack
$ ln -s foo.hack bar.hack
$ cd ..
$ hhvm --hphp --target hhbc -l 3 --module src  --output-dir $(pwd)/out

Expected behavior

Seen on 4.61 and below:

fredemmott@fredemmott-fbmbp foo % hhvm --hphp --target hhbc -l 3 --module src  --output-dir $(pwd)/out
running hphp...
parsing inputs...
parsing inputs took 0'00" (35218 us) wall time
creating binary HHBC files...
running HHBBC...
committing units to repo...
running HHBBC took 0'00" (196002 us) wall time
committing units to repo took 0'00" (159245 us) wall time
creating binary HHBC files took 0'00" (210305 us) wall time
all files saved in /tmp/foo/out ...
running hphp took 0'01" (1156975 us) wall time

Actual behavior

Seen on 4.62:

fredemmott@fredemmott-fbmbp foo % hhvm --hphp --target hhbc -l 3 --module src  --output-dir $(pwd)/out
running hphp...
parsing inputs...
parsing inputs took 0'00" (35182 us) wall time
creating binary HHBC files...
running HHBBC...
running HHBBC took 0'00" (4734 us) wall time
creating binary HHBC files took 0'00" (5000 us) wall time
running hphp took 0'00" (858870 us) wall time
std::exception: More than one function with the name foo. In src/foo.hack and src/bar.hack
hphp failed
running hphp took 0'00" (864919 us) wall time
fredemmott commented 4 years ago

2020.06.11 is clean, 2020.06.12 is broken

4f76c3b51c

fredemmott commented 4 years ago

T68775322

fredemmott commented 4 years ago

The fix for this is reasonably likely to intentionally break repo-auth mode if the target of the symlink is not in the repository. Symlinks pointing out the project are pretty bad already as the typechecker will not pay attention to the symlink.

@lexidor @ssandler FYI