Skip to content

pioasm: Throw syntax_error for unsupported 'rel' with irq prev/next#2854

Open
gonzalolarralde wants to merge 1 commit intoraspberrypi:developfrom
gonzalolarralde:gonzalolarralde/fix-pioasm-segfault
Open

pioasm: Throw syntax_error for unsupported 'rel' with irq prev/next#2854
gonzalolarralde wants to merge 1 commit intoraspberrypi:developfrom
gonzalolarralde:gonzalolarralde/fix-pioasm-segfault

Conversation

@gonzalolarralde
Copy link
Copy Markdown
Contributor

Replaces error() with throw syntax_error when rel is used with irq prev or irq next instructions in parser.yy. Without this fix the compiler will segfault instead of throw an error when trying to compile the following inputs:

.program irq_next_rel
.pio_version 1
    irq next set 0 rel
.program irq_prev_rel
.pio_version 1
    irq prev set 0 rel

Before this fix:

% ./bazel-bin/tools/pioasm/pioasm /var/folders/44/bgmj54wj15vbrvzxnp57kk2w0000gn/T/tmp.LC5BPmyQJb
/var/folders/44/bgmj54wj15vbrvzxnp57kk2w0000gn/T/tmp.LC5BPmyQJb:3.20-22: 'rel' is not supported for 'irq prev'
    3 |     irq prev set 0 rel
      |                    ^~~
zsh: segmentation fault  ./bazel-bin/tools/pioasm/pioasm 

After the fix:

% ./bazel-bin/tools/pioasm/pioasm /var/folders/44/bgmj54wj15vbrvzxnp57kk2w0000gn/T/tmp.LC5BPmyQJb
/var/folders/44/bgmj54wj15vbrvzxnp57kk2w0000gn/T/tmp.LC5BPmyQJb:3.20-22: 'rel' is not supported for 'irq prev'
    3 |     irq prev set 0 rel
      |                    ^~~

Replaces error() with throw syntax_error when 'rel' is used with 'irq prev' or 'irq next' instructions in parser.yy. Without this fix the compiler will segfault instead of throw an error when trying to compile the following inputs:

```
.program irq_next_rel
.pio_version 1
    irq next set 0 rel
```

```
.program irq_prev_rel
.pio_version 1
    irq prev set 0 rel
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants