Fix bug segfault/other memory bugs when concatenating string literals and list literals#18
Open
a2435191 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_Loaduses the wrong index variable. So I think the fix is just changingktoiin two different places (since this bug also affected list literal concatenation).Test Coverage
I used manual testing with
print ("abcd" "efg" 1)orprint ([1, 2, 3] [4, 5, 6] 1). If the number is1it 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
clangwith 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./asanand other changes in my testing repo.