Fix segfault when using an unknown identifier#1
Open
DimitryAndric wants to merge 1 commit intographitemaster:mainfrom
Open
Fix segfault when using an unknown identifier#1DimitryAndric wants to merge 1 commit intographitemaster:mainfrom
DimitryAndric wants to merge 1 commit intographitemaster:mainfrom
Conversation
For example, the `sin()` function is not yet supported, but when trying
`sin(pi)` it says (with UndefinedBehaviorSanitizer enabled):
```
Unknown identifier 'sin(pi)'eval.c:452:23: runtime error: member access within misaligned address 0x1a9f07e9f100011f for type 'Expression' (aka 'struct Expression'), which requires 8 byte alignment
0x1a9f07e9f100011f: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior eval.c:452:23 in
eval.c:452:23: runtime error: load of misaligned address 0x1a9f07e9f100011f for type 'enum (anonymous enum at eval.c:11:3)', which requires 8 byte alignment
0x1a9f07e9f100011f: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior eval.c:452:23 in
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==55692==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0xffff87e9f100011f (pc 0x0001001ed700 bp 0x0001001ed6fc sp 0x00016fc16fa0 T3060488)
==55692==The signal is caused by a UNKNOWN memory access.
#0 0x1001ed700 in parse_verify eval.c:452
==55692==Register values:
x[0] = 0x000000016fc16ea0 x[1] = 0x0000000000000000 x[2] = 0x0000000000000000 x[3] = 0x00000001012003d0
x[4] = 0x6a6cb03abcebc041 x[5] = 0x0000000000000000 x[6] = 0x0000000000000000 x[7] = 0x0000000000000000
x[8] = 0x1a9f07e9f100011f x[9] = 0x000000000000d810 x[10] = 0x00000000000c6230 x[11] = 0x0000000000000001
x[12] = 0x0000000000000000 x[13] = 0x00000001005b7153 x[14] = 0x0000000000000000 x[15] = 0x0000000000000000
x[16] = 0x0000000000000049 x[17] = 0x0000000100410058 x[18] = 0x0000000000000000 x[19] = 0x0000000000000000
x[20] = 0x0000000000000000 x[21] = 0x0000000000000000 x[22] = 0x0000000000000000 x[23] = 0x0000000000000000
x[24] = 0x0000000000000000 x[25] = 0x0000000000000000 x[26] = 0x0000000000000000 x[27] = 0x0000000000000000
x[28] = 0x000000016fc177c8 fp = 0x000000016fc170a0 lr = 0x00000001001ed6fc sp = 0x000000016fc16fa0
UndefinedBehaviorSanitizer can not provide additional info.
SUMMARY: UndefinedBehaviorSanitizer: SEGV eval.c:452 in parse_verify
==55692==ABORTING
```
This turns out to be due to `parse_primary()` returning `true` for
unknown identifiers. Return `false` instead, and add a newline to the
error message, similar to the other errors in this function.
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.
For example, the
sin()function is not yet supported, but when tryingsin(pi)it says (with UndefinedBehaviorSanitizer enabled):This turns out to be due to
parse_primary()returningtruefor unknown identifiers. Returnfalseinstead, and add a newline to the error message, similar to the other errors in this function.