Skip to content

Fix crash when initializing a WordAlignmentMatrix with one dimension - #16

Merged
pmachapman merged 1 commit into
masterfrom
fix_1d_matrix_crash
Aug 17, 2026
Merged

Fix crash when initializing a WordAlignmentMatrix with one dimension#16
pmachapman merged 1 commit into
masterfrom
fix_1d_matrix_crash

Conversation

@pmachapman

Copy link
Copy Markdown
Collaborator

This PR fixes a crash exposed by the e2e test for sillsdev/machine.py#336, where the target pre-translations were blank.

Interestingly, the crash only occurs on Linux and macOS: https://github.com/sillsdev/thot/actions/runs/31657210462

The training data that exposes the crash is at crash_data.zip, and can be run with a unit test along the lines of:

TEST(SymmetrizedAlignmentModelTest, crash)
{
  chdir("/home/peter/machine/docker-compose/builds/6a7be055db58e46ea2adfd2f/model");
  auto direct = make_shared<FastAlignModel>();
  direct->load("src_trg_invswm");
  auto inverse = make_shared<FastAlignModel>();
  inverse->load("src_trg_swm");

  auto* model = new SymmetrizedAlignmentModel(direct, inverse);
  model->setHeuristic(SymmetrizationHeuristic::GrowDiagFinalAnd);

  for (int i = 0; i < 74; ++i)
  {
    WordAlignmentMatrix waMatrix;
    LgProb prob = model->getTrainingAlignment(i, waMatrix);
    EXPECT_EQ((double)prob, (double)SMALL_LG_NUM);
  }
}

@pmachapman
pmachapman force-pushed the fix_1d_matrix_crash branch from 20e5823 to f482cb3 Compare August 13, 2026 01:36
Comment thread src/nlp_common/WordAlignmentMatrix.cc Outdated
Comment thread src/nlp_common/WordAlignmentMatrix.cc Outdated
Comment thread src/nlp_common/WordAlignmentMatrix.cc Outdated
@pmachapman
pmachapman force-pushed the fix_1d_matrix_crash branch from f482cb3 to 4db5cfd Compare August 16, 2026 23:09
@pmachapman
pmachapman requested a review from ddaspit August 16, 2026 23:10
@pmachapman
pmachapman merged commit 62a3284 into master Aug 17, 2026
13 checks passed
@pmachapman
pmachapman deleted the fix_1d_matrix_crash branch August 17, 2026 20:52
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 this pull request may close these issues.

2 participants