Skip to content

Fix bug segfault/other memory bugs when concatenating string literals and list literals#18

Open
a2435191 wants to merge 1 commit into
harmonylang:masterfrom
a2435191:string-literal-append-bug-fix
Open

Fix bug segfault/other memory bugs when concatenating string literals and list literals#18
a2435191 wants to merge 1 commit into
harmonylang:masterfrom
a2435191:string-literal-append-bug-fix

Conversation

@a2435191
Copy link
Copy Markdown

@a2435191 a2435191 commented May 17, 2026

Overview

I have found that print ("abcd" "efg" 1) crashes Harmony with a cryptic segfault instead of a graceful error. This is related to the string literal+string literal or list literal+list literal concatenation in ops.c/do_Load.

Changes Made

When checking that the values after the first string are also strings, the code in ops.c/do_Load uses the wrong index variable. So I think the fix is just changing k to i in two different places (since this bug also affected list literal concatenation).

Test Coverage

I used manual testing with print ("abcd" "efg" 1) or print ([1, 2, 3] [4, 5, 6] 1). If the number is 1 it causes a segfault on my machine. If it's significantly higher it can cause a bus error or silently read memory (I think I tested this last one but I'm not actually sure).

ASAN

I found it immensely helpful to be able to run clang with its address sanitizer (targeted towards ARM on my Mac, since I couldn't get it working for RISC). Maybe this could be useful to someone else. Please see ./asan and other changes in my testing repo.

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.

1 participant