Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime (unreachable!) panic in wasm-compose 0.217 #1811

Closed
rvolosatovs opened this issue Sep 20, 2024 · 1 comment
Closed

Runtime (unreachable!) panic in wasm-compose 0.217 #1811

rvolosatovs opened this issue Sep 20, 2024 · 1 comment

Comments

@rvolosatovs
Copy link
Member

Using wasi-virt from this PR bytecodealliance/WASI-Virt#92, I was able to trigger a panic in wasm-compose 0.217

RUST_BACKTRACE=1 ~/src/github.com/bytecodealliance/WASI-Virt/target/debug/wasi-virt --allow-all -o v.wasm c.wasm
thread 'main' panicked at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:616:21:
internal error: entered unreachable code: should have been handled in `TypeEncoder::component_entity_type`
stack backtrace:
   0: rust_begin_unwind
             at /rustc/791adf759cc065316f054961875052d5bc03e16c/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/791adf759cc065316f054961875052d5bc03e16c/library/core/src/panicking.rs:72:14
   2: wasm_compose::encoding::TypeEncoder::_ty
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:616:21
   3: wasm_compose::encoding::TypeEncoder::ty
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:539:19
   4: wasm_compose::encoding::TypeEncoder::component_entity_type
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:414:59
   5: wasm_compose::encoding::TypeEncoder::export
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:791:22
   6: wasm_compose::encoding::TypeEncoder::instance
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:308:26
   7: wasm_compose::encoding::TypeEncoder::component_instance_type
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:454:24
   8: wasm_compose::encoding::TypeEncoder::_ty
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:620:53
   9: wasm_compose::encoding::TypeEncoder::ty
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:539:19
  10: wasm_compose::encoding::TypeEncoder::component_entity_type
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:421:44
  11: wasm_compose::encoding::CompositionGraphEncoder::encode_item_import
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:1399:18
  12: wasm_compose::encoding::CompositionGraphEncoder::encode_imports
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:1350:29
  13: wasm_compose::encoding::CompositionGraphEncoder::encode
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/encoding.rs:1318:9
  14: wasm_compose::composer::ComponentComposer::compose
             at /Users/rvolosatovs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm-compose-0.217.0/src/composer.rs:542:9
  15: wasi_virt::WasiVirt::finish
             at /Users/rvolosatovs/src/github.com/bytecodealliance/WASI-Virt/src/lib.rs:463:34
  16: wasi_virt::main
             at /Users/rvolosatovs/src/github.com/bytecodealliance/WASI-Virt/src/bin/wasi-virt.rs:218:26
  17: core::ops::function::FnOnce::call_once
             at /rustc/791adf759cc065316f054961875052d5bc03e16c/library/core/src/ops/function.rs:250:5

Component WIT:

package root:component;

world root {
  import wasi:io/error@0.2.1;
  import wasi:io/poll@0.2.1;
  import wasi:io/streams@0.2.1;
  import wasi:cli/environment@0.2.1;
  import wasi:cli/exit@0.2.1;
  import wasi:cli/stderr@0.2.1;
  import wasi:cli/stdin@0.2.1;
  import wasi:cli/stdout@0.2.1;
  import wasi:cli/terminal-input@0.2.1;
  import wasi:cli/terminal-output@0.2.1;
  import wasi:cli/terminal-stderr@0.2.1;
  import wasi:cli/terminal-stdin@0.2.1;
  import wasi:cli/terminal-stdout@0.2.1;
  import wasi:clocks/monotonic-clock@0.2.1;
  import wasi:clocks/wall-clock@0.2.1;
  import wasi:filesystem/types@0.2.1;
  import wasi:filesystem/preopens@0.2.1;
  import wasi:http/types@0.2.1;
  import wasi:http/outgoing-handler@0.2.1;
  import wasi:random/insecure-seed@0.2.1;
  import wasi:random/insecure@0.2.1;
  import wasi:random/random@0.2.1;
  import wasi:sockets/network@0.2.1;
  import wasi:sockets/instance-network@0.2.1;
  import wasi:sockets/ip-name-lookup@0.2.1;
  import wasi:sockets/tcp@0.2.1;
  import wasi:sockets/tcp-create-socket@0.2.1;
  import wasi:sockets/udp@0.2.1;
  import wasi:sockets/udp-create-socket@0.2.1;
  import wasiext:http/ext@0.1.0;

  export wasi:io/error@0.2.1;
  export wasi:io/poll@0.2.1;
  export wasi:io/streams@0.2.1;
  export west-test:fib/fib;
  export west-test:leftpad/leftpad;
  export wasi:cli/environment@0.2.1;
  export wasi:cli/exit@0.2.1;
  export wasi:cli/stderr@0.2.1;
  export wasi:cli/stdin@0.2.1;
  export wasi:cli/stdout@0.2.1;
  export wasi:cli/terminal-input@0.2.1;
  export wasi:cli/terminal-output@0.2.1;
  export wasi:cli/terminal-stderr@0.2.1;
  export wasi:cli/terminal-stdin@0.2.1;
  export wasi:cli/terminal-stdout@0.2.1;
  export wasi:clocks/monotonic-clock@0.2.1;
  export wasi:filesystem/types@0.2.1;
  export wasi:filesystem/preopens@0.2.1;
  export wasi:http/types@0.2.1;
  export wasi:http/outgoing-handler@0.2.1;
  export wasi:random/insecure-seed@0.2.1;
  export wasi:random/insecure@0.2.1;
  export wasi:random/random@0.2.1;
  export wasi:sockets/instance-network@0.2.1;
  export wasi:sockets/ip-name-lookup@0.2.1;
  export wasi:sockets/tcp@0.2.1;
  export wasi:sockets/tcp-create-socket@0.2.1;
  export wasi:sockets/udp@0.2.1;
  export wasi:sockets/udp-create-socket@0.2.1;
  export wasiext:http/ext@0.1.0;
}
package wasi:io@0.2.1 {
  interface error {
    resource error {
      to-debug-string: func() -> string;
    }
  }
  interface poll {
    resource pollable {
      ready: func() -> bool;
      block: func();
    }

    poll: func(in: list<borrow<pollable>>) -> list<u32>;
  }
  interface streams {
    use error.{error};
    use poll.{pollable};

    resource input-stream {
      read: func(len: u64) -> result<list<u8>, stream-error>;
      blocking-read: func(len: u64) -> result<list<u8>, stream-error>;
      skip: func(len: u64) -> result<u64, stream-error>;
      blocking-skip: func(len: u64) -> result<u64, stream-error>;
      subscribe: func() -> pollable;
    }

    variant stream-error {
      last-operation-failed(error),
      closed,
    }

    resource output-stream {
      check-write: func() -> result<u64, stream-error>;
      write: func(contents: list<u8>) -> result<_, stream-error>;
      blocking-write-and-flush: func(contents: list<u8>) -> result<_, stream-error>;
      flush: func() -> result<_, stream-error>;
      blocking-flush: func() -> result<_, stream-error>;
      subscribe: func() -> pollable;
      write-zeroes: func(len: u64) -> result<_, stream-error>;
      blocking-write-zeroes-and-flush: func(len: u64) -> result<_, stream-error>;
      splice: func(src: borrow<input-stream>, len: u64) -> result<u64, stream-error>;
      blocking-splice: func(src: borrow<input-stream>, len: u64) -> result<u64, stream-error>;
    }
  }
}


package wasi:cli@0.2.1 {
  interface environment {
    get-environment: func() -> list<tuple<string, string>>;

    get-arguments: func() -> list<string>;

    initial-cwd: func() -> option<string>;
  }
  interface exit {
    exit: func(status: result);
  }
  interface stderr {
    use wasi:io/[email protected].{output-stream};

    get-stderr: func() -> output-stream;
  }
  interface stdin {
    use wasi:io/[email protected].{input-stream};

    get-stdin: func() -> input-stream;
  }
  interface stdout {
    use wasi:io/[email protected].{output-stream};

    get-stdout: func() -> output-stream;
  }
  interface terminal-input {
    resource terminal-input;
  }
  interface terminal-output {
    resource terminal-output;
  }
  interface terminal-stderr {
    use terminal-output.{terminal-output};

    get-terminal-stderr: func() -> option<terminal-output>;
  }
  interface terminal-stdin {
    use terminal-input.{terminal-input};

    get-terminal-stdin: func() -> option<terminal-input>;
  }
  interface terminal-stdout {
    use terminal-output.{terminal-output};

    get-terminal-stdout: func() -> option<terminal-output>;
  }
}


package wasi:clocks@0.2.1 {
  interface monotonic-clock {
    use wasi:io/[email protected].{pollable};

    type instant = u64;

    type duration = u64;

    now: func() -> instant;

    resolution: func() -> duration;

    subscribe-instant: func(when: instant) -> pollable;

    subscribe-duration: func(when: duration) -> pollable;
  }
  interface wall-clock {
    record datetime {
      seconds: u64,
      nanoseconds: u32,
    }
  }
}


package wasi:filesystem@0.2.1 {
  interface types {
    use wasi:io/[email protected].{input-stream, output-stream};
    use wasi:clocks/[email protected].{datetime};
    use wasi:io/[email protected].{error};

    resource descriptor {
      read-via-stream: func(offset: filesize) -> result<input-stream, error-code>;
      write-via-stream: func(offset: filesize) -> result<output-stream, error-code>;
      append-via-stream: func() -> result<output-stream, error-code>;
      advise: func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>;
      sync-data: func() -> result<_, error-code>;
      get-flags: func() -> result<descriptor-flags, error-code>;
      get-type: func() -> result<descriptor-type, error-code>;
      set-size: func(size: filesize) -> result<_, error-code>;
      set-times: func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>;
      read: func(length: filesize, offset: filesize) -> result<tuple<list<u8>, bool>, error-code>;
      write: func(buffer: list<u8>, offset: filesize) -> result<filesize, error-code>;
      read-directory: func() -> result<directory-entry-stream, error-code>;
      sync: func() -> result<_, error-code>;
      create-directory-at: func(path: string) -> result<_, error-code>;
      stat: func() -> result<descriptor-stat, error-code>;
      stat-at: func(path-flags: path-flags, path: string) -> result<descriptor-stat, error-code>;
      set-times-at: func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>;
      link-at: func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow<descriptor>, new-path: string) -> result<_, error-code>;
      open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result<descriptor, error-code>;
      readlink-at: func(path: string) -> result<string, error-code>;
      remove-directory-at: func(path: string) -> result<_, error-code>;
      rename-at: func(old-path: string, new-descriptor: borrow<descriptor>, new-path: string) -> result<_, error-code>;
      symlink-at: func(old-path: string, new-path: string) -> result<_, error-code>;
      unlink-file-at: func(path: string) -> result<_, error-code>;
      is-same-object: func(other: borrow<descriptor>) -> bool;
      metadata-hash: func() -> result<metadata-hash-value, error-code>;
      metadata-hash-at: func(path-flags: path-flags, path: string) -> result<metadata-hash-value, error-code>;
    }

    type filesize = u64;

    enum error-code {
      access,
      would-block,
      already,
      bad-descriptor,
      busy,
      deadlock,
      quota,
      exist,
      file-too-large,
      illegal-byte-sequence,
      in-progress,
      interrupted,
      invalid,
      io,
      is-directory,
      loop,
      too-many-links,
      message-size,
      name-too-long,
      no-device,
      no-entry,
      no-lock,
      insufficient-memory,
      insufficient-space,
      not-directory,
      not-empty,
      not-recoverable,
      unsupported,
      no-tty,
      no-such-device,
      overflow,
      not-permitted,
      pipe,
      read-only,
      invalid-seek,
      text-file-busy,
      cross-device,
    }

    enum advice {
      normal,
      sequential,
      random,
      will-need,
      dont-need,
      no-reuse,
    }

    flags descriptor-flags {
      read,
      write,
      file-integrity-sync,
      data-integrity-sync,
      requested-write-sync,
      mutate-directory,
    }

    enum descriptor-type {
      unknown,
      block-device,
      character-device,
      directory,
      fifo,
      symbolic-link,
      regular-file,
      socket,
    }

    variant new-timestamp {
      no-change,
      now,
      timestamp(datetime),
    }

    resource directory-entry-stream {
      read-directory-entry: func() -> result<option<directory-entry>, error-code>;
    }

    type link-count = u64;

    record descriptor-stat {
      %type: descriptor-type,
      link-count: link-count,
      size: filesize,
      data-access-timestamp: option<datetime>,
      data-modification-timestamp: option<datetime>,
      status-change-timestamp: option<datetime>,
    }

    flags path-flags {
      symlink-follow,
    }

    flags open-flags {
      create,
      directory,
      exclusive,
      truncate,
    }

    record metadata-hash-value {
      lower: u64,
      upper: u64,
    }

    record directory-entry {
      %type: descriptor-type,
      name: string,
    }

    filesystem-error-code: func(err: borrow<error>) -> option<error-code>;
  }
  interface preopens {
    use types.{descriptor};

    get-directories: func() -> list<tuple<descriptor, string>>;
  }
}


package wasi:http@0.2.1 {
  interface types {
    use wasi:clocks/[email protected].{duration};
    use wasi:io/[email protected].{input-stream};
    use wasi:io/[email protected].{pollable};
    use wasi:io/[email protected].{output-stream};
    use wasi:io/[email protected].{error as io-error};

    resource fields {
      constructor();
      from-list: static func(entries: list<tuple<field-key, field-value>>) -> result<fields, header-error>;
      get: func(name: field-key) -> list<field-value>;
      has: func(name: field-key) -> bool;
      set: func(name: field-key, value: list<field-value>) -> result<_, header-error>;
      delete: func(name: field-key) -> result<_, header-error>;
      append: func(name: field-key, value: field-value) -> result<_, header-error>;
      entries: func() -> list<tuple<field-key, field-value>>;
      clone: func() -> fields;
    }

    type field-key = string;

    type field-value = list<u8>;

    variant header-error {
      invalid-syntax,
      forbidden,
      immutable,
    }

    resource incoming-request {
      method: func() -> method;
      path-with-query: func() -> option<string>;
      scheme: func() -> option<scheme>;
      authority: func() -> option<string>;
      headers: func() -> headers;
      consume: func() -> result<incoming-body>;
    }

    variant method {
      get,
      head,
      post,
      put,
      delete,
      connect,
      options,
      trace,
      patch,
      other(string),
    }

    variant scheme {
      HTTP,
      HTTPS,
      other(string),
    }

    type headers = fields;

    resource incoming-body {
      %stream: func() -> result<input-stream>;
      finish: static func(this: incoming-body) -> future-trailers;
    }

    resource outgoing-request {
      constructor(headers: headers);
      body: func() -> result<outgoing-body>;
      method: func() -> method;
      set-method: func(method: method) -> result;
      path-with-query: func() -> option<string>;
      set-path-with-query: func(path-with-query: option<string>) -> result;
      scheme: func() -> option<scheme>;
      set-scheme: func(scheme: option<scheme>) -> result;
      authority: func() -> option<string>;
      set-authority: func(authority: option<string>) -> result;
      headers: func() -> headers;
    }

    resource outgoing-body {
      write: func() -> result<output-stream>;
      finish: static func(this: outgoing-body, trailers: option<trailers>) -> result<_, error-code>;
    }

    resource request-options {
      constructor();
      connect-timeout: func() -> option<duration>;
      set-connect-timeout: func(duration: option<duration>) -> result;
      first-byte-timeout: func() -> option<duration>;
      set-first-byte-timeout: func(duration: option<duration>) -> result;
      between-bytes-timeout: func() -> option<duration>;
      set-between-bytes-timeout: func(duration: option<duration>) -> result;
    }

    resource response-outparam {
      set: static func(param: response-outparam, response: result<outgoing-response, error-code>);
    }

    resource outgoing-response {
      constructor(headers: headers);
      status-code: func() -> status-code;
      set-status-code: func(status-code: status-code) -> result;
      headers: func() -> headers;
      body: func() -> result<outgoing-body>;
    }

    record DNS-error-payload {
      rcode: option<string>,
      info-code: option<u16>,
    }

    record TLS-alert-received-payload {
      alert-id: option<u8>,
      alert-message: option<string>,
    }

    record field-size-payload {
      field-name: option<string>,
      field-size: option<u32>,
    }

    variant error-code {
      DNS-timeout,
      DNS-error(DNS-error-payload),
      destination-not-found,
      destination-unavailable,
      destination-IP-prohibited,
      destination-IP-unroutable,
      connection-refused,
      connection-terminated,
      connection-timeout,
      connection-read-timeout,
      connection-write-timeout,
      connection-limit-reached,
      TLS-protocol-error,
      TLS-certificate-error,
      TLS-alert-received(TLS-alert-received-payload),
      HTTP-request-denied,
      HTTP-request-length-required,
      HTTP-request-body-size(option<u64>),
      HTTP-request-method-invalid,
      HTTP-request-URI-invalid,
      HTTP-request-URI-too-long,
      HTTP-request-header-section-size(option<u32>),
      HTTP-request-header-size(option<field-size-payload>),
      HTTP-request-trailer-section-size(option<u32>),
      HTTP-request-trailer-size(field-size-payload),
      HTTP-response-incomplete,
      HTTP-response-header-section-size(option<u32>),
      HTTP-response-header-size(field-size-payload),
      HTTP-response-body-size(option<u64>),
      HTTP-response-trailer-section-size(option<u32>),
      HTTP-response-trailer-size(field-size-payload),
      HTTP-response-transfer-coding(option<string>),
      HTTP-response-content-coding(option<string>),
      HTTP-response-timeout,
      HTTP-upgrade-failed,
      HTTP-protocol-error,
      loop-detected,
      configuration-error,
      internal-error(option<string>),
    }

    resource incoming-response {
      status: func() -> status-code;
      headers: func() -> headers;
      consume: func() -> result<incoming-body>;
    }

    type status-code = u16;

    resource future-trailers {
      subscribe: func() -> pollable;
      get: func() -> option<result<result<option<trailers>, error-code>>>;
    }

    type trailers = fields;

    resource future-incoming-response {
      subscribe: func() -> pollable;
      get: func() -> option<result<result<incoming-response, error-code>>>;
    }

    http-error-code: func(err: borrow<io-error>) -> option<error-code>;
  }
  interface outgoing-handler {
    use types.{outgoing-request, request-options, future-incoming-response, error-code};

    handle: func(request: outgoing-request, options: option<request-options>) -> result<future-incoming-response, error-code>;
  }
}


package wasi:random@0.2.1 {
  interface insecure-seed {
    insecure-seed: func() -> tuple<u64, u64>;
  }
  interface insecure {
    get-insecure-random-bytes: func(len: u64) -> list<u8>;

    get-insecure-random-u64: func() -> u64;
  }
  interface random {
    get-random-bytes: func(len: u64) -> list<u8>;

    get-random-u64: func() -> u64;
  }
}


package wasi:sockets@0.2.1 {
  interface network {
    resource network;

    type ipv4-address = tuple<u8, u8, u8, u8>;

    type ipv6-address = tuple<u16, u16, u16, u16, u16, u16, u16, u16>;

    variant ip-address {
      ipv4(ipv4-address),
      ipv6(ipv6-address),
    }

    enum error-code {
      unknown,
      access-denied,
      not-supported,
      invalid-argument,
      out-of-memory,
      timeout,
      concurrency-conflict,
      not-in-progress,
      would-block,
      invalid-state,
      new-socket-limit,
      address-not-bindable,
      address-in-use,
      remote-unreachable,
      connection-refused,
      connection-reset,
      connection-aborted,
      datagram-too-large,
      name-unresolvable,
      temporary-resolver-failure,
      permanent-resolver-failure,
    }

    record ipv4-socket-address {
      port: u16,
      address: ipv4-address,
    }

    record ipv6-socket-address {
      port: u16,
      flow-info: u32,
      address: ipv6-address,
      scope-id: u32,
    }

    variant ip-socket-address {
      ipv4(ipv4-socket-address),
      ipv6(ipv6-socket-address),
    }

    enum ip-address-family {
      ipv4,
      ipv6,
    }
  }
  interface instance-network {
    use network.{network};

    instance-network: func() -> network;
  }
  interface ip-name-lookup {
    use network.{ip-address, error-code};
    use wasi:io/[email protected].{pollable};
    use network.{network};

    resource resolve-address-stream {
      resolve-next-address: func() -> result<option<ip-address>, error-code>;
      subscribe: func() -> pollable;
    }

    resolve-addresses: func(network: borrow<network>, name: string) -> result<resolve-address-stream, error-code>;
  }
  interface tcp {
    use network.{network, ip-socket-address, error-code};
    use wasi:io/[email protected].{input-stream, output-stream};
    use network.{ip-address-family};
    use wasi:clocks/[email protected].{duration};
    use wasi:io/[email protected].{pollable};

    resource tcp-socket {
      start-bind: func(network: borrow<network>, local-address: ip-socket-address) -> result<_, error-code>;
      finish-bind: func() -> result<_, error-code>;
      start-connect: func(network: borrow<network>, remote-address: ip-socket-address) -> result<_, error-code>;
      finish-connect: func() -> result<tuple<input-stream, output-stream>, error-code>;
      start-listen: func() -> result<_, error-code>;
      finish-listen: func() -> result<_, error-code>;
      accept: func() -> result<tuple<tcp-socket, input-stream, output-stream>, error-code>;
      local-address: func() -> result<ip-socket-address, error-code>;
      remote-address: func() -> result<ip-socket-address, error-code>;
      is-listening: func() -> bool;
      address-family: func() -> ip-address-family;
      set-listen-backlog-size: func(value: u64) -> result<_, error-code>;
      keep-alive-enabled: func() -> result<bool, error-code>;
      set-keep-alive-enabled: func(value: bool) -> result<_, error-code>;
      keep-alive-idle-time: func() -> result<duration, error-code>;
      set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>;
      keep-alive-interval: func() -> result<duration, error-code>;
      set-keep-alive-interval: func(value: duration) -> result<_, error-code>;
      keep-alive-count: func() -> result<u32, error-code>;
      set-keep-alive-count: func(value: u32) -> result<_, error-code>;
      hop-limit: func() -> result<u8, error-code>;
      set-hop-limit: func(value: u8) -> result<_, error-code>;
      receive-buffer-size: func() -> result<u64, error-code>;
      set-receive-buffer-size: func(value: u64) -> result<_, error-code>;
      send-buffer-size: func() -> result<u64, error-code>;
      set-send-buffer-size: func(value: u64) -> result<_, error-code>;
      subscribe: func() -> pollable;
      shutdown: func(shutdown-type: shutdown-type) -> result<_, error-code>;
    }

    enum shutdown-type {
      receive,
      send,
      both,
    }
  }
  interface tcp-create-socket {
    use network.{ip-address-family};
    use tcp.{tcp-socket};
    use network.{error-code, network};

    create-tcp-socket: func(address-family: ip-address-family) -> result<tcp-socket, error-code>;
  }
  interface udp {
    use network.{network, ip-socket-address, error-code, ip-address-family};
    use wasi:io/[email protected].{pollable};

    resource udp-socket {
      start-bind: func(network: borrow<network>, local-address: ip-socket-address) -> result<_, error-code>;
      finish-bind: func() -> result<_, error-code>;
      %stream: func(remote-address: option<ip-socket-address>) -> result<tuple<incoming-datagram-stream, outgoing-datagram-stream>, error-code>;
      local-address: func() -> result<ip-socket-address, error-code>;
      remote-address: func() -> result<ip-socket-address, error-code>;
      address-family: func() -> ip-address-family;
      unicast-hop-limit: func() -> result<u8, error-code>;
      set-unicast-hop-limit: func(value: u8) -> result<_, error-code>;
      receive-buffer-size: func() -> result<u64, error-code>;
      set-receive-buffer-size: func(value: u64) -> result<_, error-code>;
      send-buffer-size: func() -> result<u64, error-code>;
      set-send-buffer-size: func(value: u64) -> result<_, error-code>;
      subscribe: func() -> pollable;
    }

    resource incoming-datagram-stream {
      receive: func(max-results: u64) -> result<list<incoming-datagram>, error-code>;
      subscribe: func() -> pollable;
    }

    resource outgoing-datagram-stream {
      check-send: func() -> result<u64, error-code>;
      send: func(datagrams: list<outgoing-datagram>) -> result<u64, error-code>;
      subscribe: func() -> pollable;
    }

    record incoming-datagram {
      data: list<u8>,
      remote-address: ip-socket-address,
    }

    record outgoing-datagram {
      data: list<u8>,
      remote-address: option<ip-socket-address>,
    }
  }
  interface udp-create-socket {
    use network.{ip-address-family};
    use udp.{udp-socket};
    use network.{error-code, network};

    create-udp-socket: func(address-family: ip-address-family) -> result<udp-socket, error-code>;
  }
}


package wasiext:http@0.1.0 {
  interface ext {
    use wasi:http/[email protected].{response-outparam, future-incoming-response, outgoing-request, incoming-request};

    new-response-outparam: func() -> tuple<response-outparam, future-incoming-response>;

    new-incoming-request: func(req: outgoing-request) -> incoming-request;
  }
}


package west-test:fib {
  interface fib {
    fib: func(n: u32) -> u64;
  }
}


package west-test:leftpad {
  interface leftpad {
    use wasi:io/[email protected].{input-stream, output-stream, stream-error};

    leftpad: func(in: input-stream, out: borrow<output-stream>, len: u64, c: char) -> result<_, stream-error>;
  }
}
@rvolosatovs rvolosatovs changed the title Runtime panic in wasm-compose 0.217 Runtime (unreachable!) panic in wasm-compose 0.217 Sep 20, 2024
@alexcrichton
Copy link
Member

Given that this is likely a duplicate of #1565 I'm going to close this in favor of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants