fix(bibleverse): fix gui stack overflow after firmware update
Gui task stack is 4096 with 2800 free min. After recent driver migrations, app overflowed: - verse_buf[2048] on stack in show_current_verse - bin_path[320]+idx_path[320] in load_book - temp[512] in parse_books_json Caused 'stack overflow in task gui' + LoadProhibited in sdmmc/stat path. Fix: - MAX_PATH 320 -> 128 (paths <80 chars) - temp 512 -> 256 - verse_buf stack -> heap malloc/free - ref buffers reduced Also bump manifest to V2 (0.2) required by SDK 0.8.0-dev and versionCode 2. Tested on 192.168.68.132 (ES3C28P): loads 66 books, displays verse, no reboot.
This commit is contained in:
@@ -33,7 +33,7 @@ LV_FONT_DECLARE(georgia_regular_24)
|
|||||||
#define MAX_BIBLE_BOOKS 66
|
#define MAX_BIBLE_BOOKS 66
|
||||||
#define MAX_BOOK_NAME 40
|
#define MAX_BOOK_NAME 40
|
||||||
#define MAX_VERSE_TEXT 2048
|
#define MAX_VERSE_TEXT 2048
|
||||||
#define MAX_PATH 320
|
#define MAX_PATH 128
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
@@ -239,7 +239,7 @@ static bool parse_books_json(AppCtx* ctx, const char* json_str) {
|
|||||||
const char* obj_end = strchr(obj_start, '}');
|
const char* obj_end = strchr(obj_start, '}');
|
||||||
if (!obj_end) break;
|
if (!obj_end) break;
|
||||||
// parse fields within obj_start..obj_end
|
// parse fields within obj_start..obj_end
|
||||||
char temp[512];
|
char temp[256];
|
||||||
size_t len = (size_t)(obj_end - obj_start + 1);
|
size_t len = (size_t)(obj_end - obj_start + 1);
|
||||||
if (len >= sizeof(temp)) len = sizeof(temp)-1;
|
if (len >= sizeof(temp)) len = sizeof(temp)-1;
|
||||||
memcpy(temp, obj_start, len);
|
memcpy(temp, obj_start, len);
|
||||||
@@ -672,27 +672,27 @@ static void show_current_verse(AppCtx* ctx) {
|
|||||||
const char* text_ptr = "(empty)";
|
const char* text_ptr = "(empty)";
|
||||||
if (off < ctx->book_bin_size) text_ptr = (const char*)(ctx->book_bin + off);
|
if (off < ctx->book_bin_size) text_ptr = (const char*)(ctx->book_bin + off);
|
||||||
|
|
||||||
char verse_buf[MAX_VERSE_TEXT];
|
// Fix stack overflow: verse_buf was 2048 bytes on stack, causing gui task (4096) overflow
|
||||||
strncpy(verse_buf, text_ptr, sizeof(verse_buf)-1);
|
// Use heap allocation
|
||||||
verse_buf[sizeof(verse_buf)-1]='\0';
|
char* verse_buf = (char*)malloc(MAX_VERSE_TEXT);
|
||||||
|
if (!verse_buf) {
|
||||||
|
ESP_LOGE(TAG, "Failed to malloc verse_buf");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
strncpy(verse_buf, text_ptr, MAX_VERSE_TEXT-1);
|
||||||
|
verse_buf[MAX_VERSE_TEXT-1]='\0';
|
||||||
|
|
||||||
char ref_buf[96];
|
char ref_buf[64];
|
||||||
snprintf(ref_buf, sizeof(ref_buf), "%s %d:%d", ctx->books[ctx->cur_book_idx].bname, vi->cnum, vi->vnum);
|
snprintf(ref_buf, sizeof(ref_buf), "%s %d:%d", ctx->books[ctx->cur_book_idx].bname, vi->cnum, vi->vnum);
|
||||||
|
|
||||||
// Editorial reference style like your image: "PSALMS 23:1" with tracking
|
char ref_pretty[80];
|
||||||
char ref_pretty[108];
|
char bname_upper[40];
|
||||||
// Use uppercase for book? Keep title for now but uppercase style for editorial match
|
|
||||||
// We'll format as "— PSALMS 23:1 —" feel? For dark mode keep minimal like ref image
|
|
||||||
// Reference image shows lines flanking citation - we do with letterspacing + dim
|
|
||||||
// For now: "PSALMS 23:1" style - uppercase via runtime? We'll uppercase book name
|
|
||||||
char bname_upper[48];
|
|
||||||
strncpy(bname_upper, ctx->books[ctx->cur_book_idx].bname, sizeof(bname_upper)-1);
|
strncpy(bname_upper, ctx->books[ctx->cur_book_idx].bname, sizeof(bname_upper)-1);
|
||||||
bname_upper[sizeof(bname_upper)-1]='\0';
|
bname_upper[sizeof(bname_upper)-1]='\0';
|
||||||
for (char* p=bname_upper; *p; ++p) *p = toupper((unsigned char)*p);
|
for (char* p=bname_upper; *p; ++p) *p = toupper((unsigned char)*p);
|
||||||
snprintf(ref_pretty, sizeof(ref_pretty), "%s %d:%d", bname_upper, vi->cnum, vi->vnum);
|
snprintf(ref_pretty, sizeof(ref_pretty), "%s %d:%d", bname_upper, vi->cnum, vi->vnum);
|
||||||
|
|
||||||
if (ctx->lbl_verse) {
|
if (ctx->lbl_verse) {
|
||||||
// start faded for transition
|
|
||||||
lv_obj_set_style_text_opa(ctx->lbl_verse, 60, 0);
|
lv_obj_set_style_text_opa(ctx->lbl_verse, 60, 0);
|
||||||
lv_label_set_text(ctx->lbl_verse, verse_buf);
|
lv_label_set_text(ctx->lbl_verse, verse_buf);
|
||||||
apply_verse_scaling(ctx, verse_buf);
|
apply_verse_scaling(ctx, verse_buf);
|
||||||
@@ -741,6 +741,7 @@ static void show_current_verse(AppCtx* ctx) {
|
|||||||
if (ctx->cur_global >= ctx->total_verses-1) lv_obj_add_state(ctx->btn_next, LV_STATE_DISABLED);
|
if (ctx->cur_global >= ctx->total_verses-1) lv_obj_add_state(ctx->btn_next, LV_STATE_DISABLED);
|
||||||
else lv_obj_clear_state(ctx->btn_next, LV_STATE_DISABLED);
|
else lv_obj_clear_state(ctx->btn_next, LV_STATE_DISABLED);
|
||||||
}
|
}
|
||||||
|
free(verse_buf);
|
||||||
save_progress(ctx);
|
save_progress(ctx);
|
||||||
verse_fade_in(ctx);
|
verse_fade_in(ctx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
[manifest]
|
manifest.version=0.2
|
||||||
version=0.1
|
target.sdk=0.8.0-dev
|
||||||
[target]
|
target.platforms=esp32s3,esp32p4
|
||||||
sdk=0.8.0-dev
|
app.id=one.tactility.bibleverse
|
||||||
platforms=esp32s3,esp32p4
|
app.version.name=0.1.0
|
||||||
[app]
|
app.version.code=2
|
||||||
id=one.tactility.bibleverse
|
app.name=Bible Verse
|
||||||
versionName=0.1.0
|
app.description=Single verse at a time, advances each minute. Tap to show controls.
|
||||||
versionCode=1
|
|
||||||
name=Bible Verse
|
|
||||||
description=Single verse at a time, advances each minute. Tap to show controls.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user