Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert fails in llvm::BitcodeWriter::~BitcodeWriter() during some tests #514

Closed
sogartar opened this issue Dec 10, 2021 · 5 comments · Fixed by #515
Closed

Assert fails in llvm::BitcodeWriter::~BitcodeWriter() during some tests #514

sogartar opened this issue Dec 10, 2021 · 5 comments · Fixed by #515
Assignees

Comments

@sogartar
Copy link

🐛 Bug

When running some of the tests and LLVM is built in debug, an assert in fails llvm::BitcodeWriter::~BitcodeWriter().

I encountered this when doing the CMake build PR. There LLVM could be built in debug, wheres it seems the Bazel build uses a prebuilt release version, so the assert is suppressed.
It appears in tests related to SHA.

To Reproduce

Steps to reproduce the behavior:

  1. Checkout https://github.com/sogartar/CompilerGym/tree/boian-cmake-2 and build with CMake in debug. Use -DCMAKE_BUILD_TYPE=debug as an argument during configuration.
  2. Run the tests from the binary directory with
    ctest -j5 -R tests/fuzzing/llvm_stress_fuzz_test\|tests/llvm/fresh_environment_observation_reward_test\|tests/llvm/llvm_env_test\|tests/llvm/observation_spaces_test\|tests/llvm/validation_regression_test
    

One of the errors that appears:

compiler_gym-llvm-service: /home/petkantchin/ws/nodlabs/compiler_gym/build/ninja/debug/external/llvm/llvm/src/llvm/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:4370: llvm::BitcodeWriter::~BitcodeWriter(): Assertion `WroteStrtab' failed.

LastTest.log

Expected behavior

No assert should be triggered.
It may be the case that there should be no assert in the LLVM code.

Environment

Please fill in this checklist:

  • CompilerGym: https://github.com/sogartar/CompilerGym/tree/boian-cmake-2
  • How you installed CompilerGym (conda, pip, source): source
  • OS: Ubuntu 20.04
  • Python version: 3.8
  • Build command you used (if compiling from source): build instructions for CMake from INSTALL.md
  • GCC/clang version (if compiling from source): clang-9
  • Bazel version (if compiling from source):
  • Versions of any other relevant libraries: LLVM in debug
ChrisCummins added a commit to ChrisCummins/CompilerGym that referenced this issue Dec 13, 2021
Use the WriteBitcodeToFile() function rather than
BitcodeWriter::writeMethod() method to prevent a debugging assertion.

Issue facebookresearch#514.
@ChrisCummins
Copy link
Contributor

Hi @sogartar, thanks for the report!

Without being familiar with the code, I had a bit of a hard time understanding why this assert is thrown given the lack of comments: https://github.com/llvm/llvm-project/blob/d32170dbd5b0d54436537b6b75beaf44324e0c28/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp#L4370

However it seems like the problem will go away if I just swap one API call for another. I'm going to post a PR, would you mind checking if this fixes the debug build?

Cheers,
Chris

ChrisCummins added a commit to ChrisCummins/CompilerGym that referenced this issue Dec 13, 2021
Use the WriteBitcodeToFile() function rather than
BitcodeWriter::writeMethod() method to prevent a debugging assertion.

Issue facebookresearch#514.
ChrisCummins added a commit to ChrisCummins/CompilerGym that referenced this issue Dec 13, 2021
Use the WriteBitcodeToFile() function rather than
BitcodeWriter::writeMethod() method to prevent a debugging assertion.

Issue facebookresearch#514.
@sogartar
Copy link
Author

I just ran the failing tests against the PR. Here is the log LastTest.log.

I noticed that this assert does not fail. The tests/llvm/llvm_env_test test now passes.

The other tests are still failing. Namely,

  • tests/fuzzing/llvm_stress_fuzz_test
  • tests/llvm/fresh_environment_observation_reward_test
  • tests/llvm/observation_spaces_test
  • tests/llvm/validation_regression_test

Most likely the other errors are unrelated to BitcodeWriter's destructor.

All tests "generally" pass under release build.

tests/llvm/validation_regression_test occasionally hangs under release.
On one occasion tests/fuzzing/llvm_stress_fuzz_test failed with LastTest.log.
I am not sure these problems are related only to this PR.

@ChrisCummins
Copy link
Contributor

Hi @sogartar, I'm just going back over some issues. Was this one fixed? I'm not sure why I closed it :)

@sogartar
Copy link
Author

This is fixed.

@ChrisCummins
Copy link
Contributor

Ok thanks!

@ChrisCummins ChrisCummins self-assigned this Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants