Skip to content

Fix LateInitializationError in Llama dispose method #71

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

Merged
merged 1 commit into from
Jul 26, 2025

Conversation

Anees004
Copy link
Contributor

This commit fixes a critical bug that causes LateInitializationError when the Llama constructor fails during initialization.

Problem:

  • dispose() method is called during constructor failure
  • dispose() tries to access uninitialized late fields
  • Results in LateInitializationError crash

Solution:

  • Add _isInitialized flag to track initialization state
  • Only access late fields in dispose() when initialization is complete
  • Add try-catch around batch.free() for additional safety
  • Ensure batch is always initialized to prevent null reference errors

Testing:

  • Verified fix prevents crashes
  • Maintains backward compatibility
  • Allows graceful fallback to mock mode

This commit fixes a critical bug that causes LateInitializationError when the Llama constructor fails during initialization.

Problem:
- dispose() method is called during constructor failure
- dispose() tries to access uninitialized late fields
- Results in LateInitializationError crash

Solution:
- Add _isInitialized flag to track initialization state
- Only access late fields in dispose() when initialization is complete
- Add try-catch around batch.free() for additional safety
- Ensure batch is always initialized to prevent null reference errors

Testing:
- Verified fix prevents crashes
- Maintains backward compatibility
- Allows graceful fallback to mock mode
@Anees004
Copy link
Contributor Author

LateInitializationError error fix

@netdur netdur self-assigned this Jul 22, 2025
@netdur netdur merged commit 8ee7021 into netdur:main Jul 26, 2025
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