Skip to content

fix: move SecureHttpClient's 2 KB read buffer off the stack - #68

Merged
prokrypt merged 2 commits into
developmentfrom
fix/securehttp-readbuf-heap
Sep 30, 2026
Merged

prokrypt merged 2 commits into
developmentfrom
fix/securehttp-readbuf-heap

Conversation

@prokrypt

Copy link
Copy Markdown
Owner

Before: SecureHttpClient's readFixed() and readUntilClose() each held a 2 KB stack buffer under every body callback and abort poll. OPDS feed parsing, KOReader sync and input polling during a fetch ran 2 KB deeper on the calling task.

After: the buffer is heap-allocated on the first body read and freed with the client, which lives for one request. Each frame drops from 2112 B to 48 B.

How: freeink-sdk 838622e → c5919cf, which is SDK 34aebf6 (CrossDink's fix) cherry-picked onto the current pin. None of CrossDink's display commits come along. It is on fork branch fix/securehttp-readbuf-heap. If the allocation fails, the read returns false and the request fails like any other read error.

Sizes vs development 2dc4839 (static RAM unchanged on both):

  • C3 (default): flash +80 B (6,296,057 → 6,296,137), mostly the longer branch name in the build info. RAM 65,232 → 65,232
  • x4-pro-light-sleep: flash −32 B (5,600,829 → 5,600,797), RAM 118,452 → 118,452
  • Runtime: 2 KB less stack, 2 KB more heap while a secure request runs.

Verify on hardware: browse and download from an OPDS catalog and run a KOReader sync. Both should work as before, and the loopTask stack high-water mark during a catalog load should be about 2 KB higher.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XgLRarbAmBVepTPKCK7mgd


Generated by Claude Code

freeink-sdk 838622e -> c5919cf (34aebf6 cherry-picked onto the current
pin): readFixed() and readUntilClose() held a 2 KB stack buffer under
every body callback and abort poll, so OPDS feed parsing and KOSync ran
2 KB deeper on the calling task. The buffer is now allocated on the first
body and freed with the client.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XgLRarbAmBVepTPKCK7mgd
@prokrypt
prokrypt merged commit 76473c2 into development Sep 30, 2026
12 checks passed
@prokrypt
prokrypt deleted the fix/securehttp-readbuf-heap branch September 30, 2026 17:11
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