metaeducation / ren-c

Library for embedding a Rebol interpreter into C codebases
GNU Lesser General Public License v3.0
126 stars 27 forks source link

Unsafe Error: TRANSCODE of arbitrary binary #1111

Closed rgchris closed 3 years ago

rgchris commented 3 years ago

In ReplPad, this gives an unsafe error:

>> transcode #{DECAFBAD}
** UNSAFE ERROR ENCOUNTERED IN CONSOLE SKIN
** REVERTING TO DEFAULT SKIN
** HOST-CONSOLE ACTION! ITSELF RAISED ERROR
** SAFE RECOVERY NOT LIKELY, BUT TRYING ANYWAY
** REVERTING TO DEFAULT SKIN
[#host-console-error]
** Script Error: invalid UTF-8 byte sequence found during decoding
** Where: mold then if if ext-console-impl entrap main
** Near: [***
    print mold prior **
]
** Line: 307

I suspect it should be some kind of syntax or UTF-8 error.

In older builds (this one built 30-Jul-2020), the interpreter bombs:

>> transcode #{DECAFBAD}
Assertion failed: (utf8 != NULL), function Hash_UTF8, file ../src/core/s-crc.c, line 154.
Abort trap: 6

And R3C branch:

>> transcode #{DECAFBAD}
Segmentation fault: 11
hostilefork commented 3 years ago

R3-Alpha didn't validate word scans for UTF8, it just said "oh this byte sequence looks like a word" and interned it.

r3-alpha>> type? first transcode #{DECAFBAD}
== word!

So this is all part of the slow process of Ren-C speaking up when noticing something is wrong. Good news is that there's distinct datatypes now for "validated utf8 byte sequence" and "not yet validated utf8 byte sequence". If that datatype had been honored here, it wouldn't have been able to compile the code that assumed the sequence was checked when it wasn't.

Fixed now: https://github.com/metaeducation/ren-c/commit/77f61f700f500420e1b377bc294642417f288a1e

rgchris commented 3 years ago

@hostilefork I don't know if it was this fix, but ReplPad isn't booting now

hostilefork commented 3 years ago

Boots for me in Chrome, Edge, and Firefox...and passed the greenlight test on the build server (headless firefox)

rgchris commented 3 years ago

Tested on Firefox and Chrome—shows the usual whirr of text then goes blank showing only the yellow sticky.

Screen Shot

hostilefork commented 3 years ago

What does the JavaScript console say? What is the git commit in the lib-r3.js file in the network tab? (Console should print that, too)

hostilefork commented 3 years ago

Make sure you don't have files cached. If the .reb files are cached, they can be stale. Ctrl-Shift-R for full refresh, or whatever.

rgchris commented 3 years ago

Hm, turned on the panel in Chrome and it loaded. Must be caching—tried force refreshing, I guess it didn't take. In Firefox:

console

rgchris commented 3 years ago

Ok, cleared cache, is working.