Commit af899ceb authored by Kenton Varda's avatar Kenton Varda

Don't fail evolution-test when it triggers issue #344.

parent 8ba8d95b
......@@ -868,6 +868,18 @@ public:
}
kj::MainBuilder::Validity run() {
// https://github.com/sandstorm-io/capnproto/issues/344 describes an obscure bug in the layout
// algorithm, the fix for which breaks backwards-compatibility for any schema triggering the
// bug. In order to avoid silently breaking protocols, we are temporarily throwing an exception
// in cases where this bug would have occurred, so that people can decide what to do.
// However, the evolution test can occasionally trigger the bug (depending on the random path
// it takes). Rather than try to avoid it, we disable the exception-throwing, because the bug
// is actually fixed, and the exception is only there to raise awareness of the compatibility
// concerns.
//
// On Linux, seed 1467142714 (for example) will trigger the exception (without this env var).
setenv("CAPNP_IGNORE_ISSUE_344", "1", true);
srand(seed);
{
......
......@@ -30,6 +30,10 @@
namespace capnp {
namespace compiler {
bool shouldDetectIssue344() {
return getenv("CAPNP_IGNORE_ISSUE_344") == nullptr;
}
class NodeTranslator::StructLayout {
// Massive, disgusting class which implements the layout algorithm, which decides the offset
// for each field.
......@@ -411,7 +415,7 @@ public:
// Underlying slot is big enough, so expand our size and update holes.
if (newHoles) {
holes.addHolesAtEnd(lgSizeUsed, 1, desiredUsage);
} else {
} else if (shouldDetectIssue344()) {
// Unfortunately, Cap'n Proto 0.5.x and below would always call addHolesAtEnd(), which
// was the wrong thing to do when called from tryExpand(), which itself is only called
// in cases involving unions nested in other unions. The bug could lead to multiple
......@@ -526,7 +530,11 @@ public:
// problem and throw an exception.
//
// TODO(cleanup): Once sufficient time has elapsed, switch to "return false;" here.
mustFail = true;
if (shouldDetectIssue344()) {
mustFail = true;
} else {
return false;
}
}
for (uint i = 0; i < parentDataLocationUsage.size(); i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment