Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

AssemblyScript: Console.log of string literal panics #53

Open
radu-matei opened this issue Apr 7, 2021 · 2 comments
Open

AssemblyScript: Console.log of string literal panics #53

radu-matei opened this issue Apr 7, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@radu-matei
Copy link
Member

radu-matei commented Apr 7, 2021

This is a weird error, so I'm opening it sooner rather than later, even with very little info.
Stumbled across this while trying to decode a header value, and it turns out that sometimes trying to Console.log (or Console.write) a string panics.

I haven't tested this outside of the current project, which is why I'm not opening this issue in as-wasi yet.

In short:

let y = "testofastringliteral";
Console.log(y);
thread 'tests::test_with_allowed_domains' panicked at 'called `Result::unwrap()` on an 
`Err` value: wasm trap: out of bounds memory access
wasm backtrace:
    0: 0x13f3 - <unknown>!~lib/rt/itcms/Object#get:color
    1: 0x15aa - <unknown>!~lib/rt/itcms/__visit
    2: 0x15dc - <unknown>!~lib/rt/itcms/visitStack
    3: 0x1dac - <unknown>!~lib/rt/itcms/step
    4: 0x1e79 - <unknown>!~lib/rt/itcms/interrupt
    5: 0x23f7 - <unknown>!~lib/rt/itcms/__new
    6: 0x3fbb - <unknown>!~lib/string/String.UTF8.encode
    7: 0x12e4 - <unknown>!~lib/as-wasi/as-wasi/Descriptor#writeStringLn
    8: 0x1361 - <unknown>!~lib/as-wasi/as-wasi/Descriptor#writeString
    9: 0x3613 - <unknown>!~lib/as-wasi/as-wasi/Console.write
   10: 0x2d31 - <unknown>!~lib/as-wasi/as-wasi/Console.log
   11: 0x395b - <unknown>!../../crates/as/index/Response#headerGet
   12: 0x3a58 - <unknown>!index/check
   13: 0x3be9 - <unknown>!index/post

The weird part is that Console.log("value" + y); will run successfully.

However, the result is that trying to just print a header value simply panics in my WIP branch.
I'll try to reproduce this and update the issue.

@radu-matei radu-matei added the bug Something isn't working label Apr 7, 2021
@radu-matei
Copy link
Member Author

I hit this again working on #58.
I will try updating the AssemblyScript compiler version and the local dependency, but this is so weird.

@radu-matei
Copy link
Member Author

I am going to assume this is related somehow to AssemblyScript/assemblyscript#2099

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant