Implementation Bookmarks
Issues that require careful surgical implementation (not simple warning fixes)
🔖 BOOKMARK #1: Clipboard 1MB Stack Buffer
File: src/clipboard/clipboard_module.f90
Line: 40
Priority: HIGH (potential stack overflow)
Current Issue
character(len=1000000) :: buffer ! 1MB buffer for clipboard content
This allocates 1MB on the stack, which can cause stack overflow crashes.
gfortran Warning
Warning: Array 'buffer' at (1) is larger than limit set by '-fmax-stack-var-size=',
moved from stack to static storage. This makes the procedure unsafe when called
recursively, or concurrently from multiple threads. Consider increasing the
'-fmax-stack-var-size=' limit (or use '-frecursive', which implies unlimited
'-fmax-stack-var-size') - or change the code to use an ALLOCATABLE array.
Recommended Solution
- Change to
character(len=:), allocatable :: buffer - Allocate dynamically:
allocate(character(len=needed_size) :: buffer) - Deallocate after use
- Consider reading clipboard in chunks if very large
Affected Functions
clipboard_paste()insrc/clipboard/clipboard_module.f90
Testing Required
- Test pasting small text
- Test pasting large text (>1MB)
- Test multiple paste operations
- Verify no memory leaks
Status
⏳ Deferred for careful manual implementation after bulk warning cleanup
Future Bookmarks
Add additional complex issues here as they're discovered...
View source
| 1 | # Implementation Bookmarks |
| 2 | |
| 3 | Issues that require careful surgical implementation (not simple warning fixes) |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | ## 🔖 BOOKMARK #1: Clipboard 1MB Stack Buffer |
| 8 | |
| 9 | **File:** `src/clipboard/clipboard_module.f90` |
| 10 | **Line:** 40 |
| 11 | **Priority:** HIGH (potential stack overflow) |
| 12 | |
| 13 | ### Current Issue |
| 14 | ```fortran |
| 15 | character(len=1000000) :: buffer ! 1MB buffer for clipboard content |
| 16 | ``` |
| 17 | |
| 18 | This allocates 1MB on the stack, which can cause stack overflow crashes. |
| 19 | |
| 20 | ### gfortran Warning |
| 21 | ``` |
| 22 | Warning: Array 'buffer' at (1) is larger than limit set by '-fmax-stack-var-size=', |
| 23 | moved from stack to static storage. This makes the procedure unsafe when called |
| 24 | recursively, or concurrently from multiple threads. Consider increasing the |
| 25 | '-fmax-stack-var-size=' limit (or use '-frecursive', which implies unlimited |
| 26 | '-fmax-stack-var-size') - or change the code to use an ALLOCATABLE array. |
| 27 | ``` |
| 28 | |
| 29 | ### Recommended Solution |
| 30 | 1. Change to `character(len=:), allocatable :: buffer` |
| 31 | 2. Allocate dynamically: `allocate(character(len=needed_size) :: buffer)` |
| 32 | 3. Deallocate after use |
| 33 | 4. Consider reading clipboard in chunks if very large |
| 34 | |
| 35 | ### Affected Functions |
| 36 | - `clipboard_paste()` in `src/clipboard/clipboard_module.f90` |
| 37 | |
| 38 | ### Testing Required |
| 39 | - Test pasting small text |
| 40 | - Test pasting large text (>1MB) |
| 41 | - Test multiple paste operations |
| 42 | - Verify no memory leaks |
| 43 | |
| 44 | ### Status |
| 45 | ⏳ Deferred for careful manual implementation after bulk warning cleanup |
| 46 | |
| 47 | --- |
| 48 | |
| 49 | ## Future Bookmarks |
| 50 | |
| 51 | Add additional complex issues here as they're discovered... |