Fix non-deterministic crash in TensorflowModelTest (#778)#781
Open
harshitsingh070 wants to merge 1 commit into
Open
Fix non-deterministic crash in TensorflowModelTest (#778)#781harshitsingh070 wants to merge 1 commit into
harshitsingh070 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.