Skip to content

Fix non-deterministic crash in TensorflowModelTest (#778)#781

Open
harshitsingh070 wants to merge 1 commit into
apache:mainfrom
harshitsingh070:fix-tensorflow-test-778
Open

Fix non-deterministic crash in TensorflowModelTest (#778)#781
harshitsingh070 wants to merge 1 commit into
apache:mainfrom
harshitsingh070:fix-tensorflow-test-778

Conversation

@harshitsingh070

Copy link
Copy Markdown
Contributor

Description

Fixes #778
What was the issue?
The TensorflowModelTest was non-deterministically failing during the Maven Surefire teardown phase, causing the build to
fail with a SIGABRT (Process Exit Code: 134) and the error: "The forked VM terminated without properly saying goodbye".

This issue was traced back to native memory resource leaks in the test file. The test utilized an unclosed Ops.create()
(which spins up a global EagerSession) and unclosed Eager Tensor instances (such as predicted , tf.constant , and
argMax ) for printing test predictions. When the JVM began shutting down, the garbage collector would attempt to clean
these up concurrently, causing a race condition and a native crash within the TensorFlow C API.

How was it fixed?

• Wrapped the predicted graph tensor in a Java try-with-resources block to ensure deterministic and safe na-tive memory
cleanup.
• Replaced the EagerSession and TensorFlow argMax operations with a standard Java nested loop to compute the argmax .

How was this tested?

[✓] Reproduced the original crash locally using mvn test -Dtest=TensorflowModelTest -pl wayang-platforms/wayang-tensorflow .
[✓] Verified that the test now reliably passes and prints the expected predictions without throwing a VM crash during JVM
teardown.

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.

Non-deterministic tensorflow test failing

1 participant