Skip to content

Commit

Permalink
fix a stale register value in dquotes.subx
Browse files Browse the repository at this point in the history
How did things seem to be working until now?
- We were saving an address from the stack to stream.read
- When we read this address in skip-chars-matching:loop, we used to stop early

But now we've moved the stack to a larger address, one where the most significant
byte is set. When the stack address now gets to skip-chars-matching:loop,
it's treated as a negative number and we proceed through the loop. At which
point we try to index into the array using it.

No real test to be written to protect against this :(
  • Loading branch information
akkartik committed May 15, 2019
1 parent 56a0f3c commit 2f49a27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Binary file modified subx/apps/dquotes
Binary file not shown.
3 changes: 2 additions & 1 deletion subx/apps/dquotes.subx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Entry: # run tests if necessary, convert stdin if not
#? # . . discard args
#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP
#? # . test()
#? e8/call test-emit-string-literal-data/disp32
#? e8/call test-convert-is-idempotent-by-default/disp32
#? 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32 # copy *Num-test-failures to EBX
#? eb/jump $main:end/disp8

Expand Down Expand Up @@ -1503,6 +1503,7 @@ $next-word:comment:
8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 0/r32/EAX 0xc/disp8 . # copy ESI+EAX+12 to EAX
89/copy 1/mod/*+disp8 7/rm32/EDI . . . 0/r32/EAX 4/disp8 . # copy EAX to *(EDI+4)
# line->read = line->write # skip rest of line
8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # copy *ESI to EAX
89/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 . # copy EAX to *(ESI+4)
# return
eb/jump $next-word:end/disp8
Expand Down

0 comments on commit 2f49a27

Please sign in to comment.