The application crashes with a segmentation fault when a second image generation is started. This appears to be caused by an issue with the progress callback mechanism.
Problem Analysis
The segmentation fault likely occurs due to:
Progress callback referring to invalid memory after first generation completes
Callback not being properly cleaned up between generations
Thread safety issues with the callback during concurrent generation requests
dangling pointers in the callback context
Expected Behavior
Multiple image generation requests should work sequentially without crashing
Progress callbacks should be properly managed across multiple generations
Memory should be correctly cleaned up after each generation completes
Implementation Plan
Investigate progress callback implementation in stable_diffusion_wrapper.cpp
Check callback lifecycle management during generation start/stop
Verify thread safety of callback mechanisms
Fix memory management issues with callback context
Test with multiple sequential generations to verify fix
Test multiple sequential image generation requests
Verify progress reporting works correctly for each generation
Check memory usage patterns during multiple generations
Ensure no memory leaks or dangling pointers remain
## Issue Description
The application crashes with a segmentation fault when a second image generation is started. This appears to be caused by an issue with the progress callback mechanism.
## Problem Analysis
The segmentation fault likely occurs due to:
1. Progress callback referring to invalid memory after first generation completes
2. Callback not being properly cleaned up between generations
3. Thread safety issues with the callback during concurrent generation requests
4. dangling pointers in the callback context
## Expected Behavior
- Multiple image generation requests should work sequentially without crashing
- Progress callbacks should be properly managed across multiple generations
- Memory should be correctly cleaned up after each generation completes
## Implementation Plan
1. **Investigate progress callback implementation** in stable_diffusion_wrapper.cpp
2. **Check callback lifecycle management** during generation start/stop
3. **Verify thread safety** of callback mechanisms
4. **Fix memory management** issues with callback context
5. **Test with multiple sequential generations** to verify fix
## Files to Examine
- `src/stable_diffusion_wrapper.cpp` - Progress callback implementation
- `src/model_manager.cpp` - Generation lifecycle management
- `include/stable_diffusion_wrapper.h` - Callback definitions
## Testing Strategy
- Test multiple sequential image generation requests
- Verify progress reporting works correctly for each generation
- Check memory usage patterns during multiple generations
- Ensure no memory leaks or dangling pointers remain
Issue Description
The application crashes with a segmentation fault when a second image generation is started. This appears to be caused by an issue with the progress callback mechanism.
Problem Analysis
The segmentation fault likely occurs due to:
Expected Behavior
Implementation Plan
Files to Examine
src/stable_diffusion_wrapper.cpp- Progress callback implementationsrc/model_manager.cpp- Generation lifecycle managementinclude/stable_diffusion_wrapper.h- Callback definitionsTesting Strategy