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

AssemblyScript: Console.log of string literal panics #53

@radu-matei

Description

@radu-matei

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions