demergent-labs / azle

A WebAssembly runtime for TypeScript and JavaScript on ICP
MIT License
208 stars 36 forks source link

Fuzz testing errors to fix #2270

Open lastmjs opened 1 day ago

lastmjs commented 1 day ago

cuzz --canister-name async_await --call-delay 0

Setting the delay to 0 has led to this error:

2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] thread '
2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] <unnamed>
2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] ' panicked at 
2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] /home/lastmjs/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rquickjs-core-0.6.2/src/safe_ref.rs
2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] :
2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 35
2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] :
2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 20
2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] :

2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] already borrowed: BorrowMutError
2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] 

2024-11-06 22:02:43.278941743 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
lastmjs commented 20 hours ago

cuzz --canister-name complex_types --call-delay .1

AgentError: Call failed:
  Canister: bkyz2-fmaaa-aaaaa-qaaaq-cai
  Method: createThread (update)
  "Request ID": "999843d3bc680b329640d3803ff28b37a65fef53b6fca70cd9c5d4fe9c3c1eac"
  "Error code": "IC0502"
  "Reject code": "5"
  "Reject message": "Error from Canister bkyz2-fmaaa-aaaaa-qaaaq-cai: Canister trapped: heap out of bounds.\nConsider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped"
    at caller (/home/lastmjs/development/cuzz/node_modules/@dfinity/agent/src/actor.ts:575:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at resultAndMemoryUsage (/home/lastmjs/development/cuzz/index.ts:188:29) {
  canisterId: Principal {
    _arr: Uint8Array(10) [
      128, 0, 0, 0, 0,
       16, 0, 1, 1, 1
    ],
    _isPrincipal: true
  },
  methodName: 'createThread',
  type: 'update',
  props: {
    'Request ID': '999843d3bc680b329640d3803ff28b37a65fef53b6fca70cd9c5d4fe9c3c1eac',
    'Error code': 'IC0502',
    'Reject code': '5',
    'Reject message': 'Error from Canister bkyz2-fmaaa-aaaaa-qaaaq-cai: Canister trapped: heap out of bounds.\n' +
      'Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped'
  },
  requestId: ArrayBuffer {
    [Uint8Contents]: <99 98 43 d3 bc 68 0b 32 96 40 d3 80 3f f2 8b 37 a6 5f ef 53 b6 fc a7 0c d9 c5 d4 fe 9c 3c 1e ac>,
    byteLength: 32
  },
  response: {
    ok: true,
    status: 200,
    statusText: 'OK',
    body: { status: 'replied', certificate: [Uint8Array] },
    headers: [ [Array], [Array], [Array], [Array] ]
  },
  reject_code: 5,
  reject_message: 'Error from Canister bkyz2-fmaaa-aaaaa-qaaaq-cai: Canister trapped: heap out of bounds.\n' +
    'Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped',
  error_code: 'IC0502'
}
lastmjs commented 10 hours ago

canister: bitcoin

error:

  requestId: ArrayBuffer {
    [Uint8Contents]: <92 ab e5 ec b1 dd 3e e5 d9 c6 6a 5b ff 4e 8a d5 3f d7 1d 90 27 db fd 99 47 47 3c 0c d3 b2 4d c0>,
    byteLength: 32
  },
  response: {
    ok: true,
    status: 200,
    statusText: 'OK',
    body: { status: 'replied', certificate: [Uint8Array] },
    headers: [ [Array], [Array], [Array], [Array] ]
  },
  reject_code: 5,
  reject_message: 'Error from Canister bkyz2-fmaaa-aaaaa-qaaaq-cai: Canister called `ic0.trap` with message: Uncaught Error: Failed to decode Candid bytes: InternalError: out of memory\n' +
    '    at idlDecode (.azle/bitcoin/main.js:4693:11)\n' +
    '    at decodeArgs (.azle/bitcoin/main.js:4668:12)\n' +
    '    at executeAndReplyWithCandidSerde (.azle/bitcoin/main.js:4662:23)\n' +
    '    at <anonymous> (.azle/bitcoin/main.js:4907:15)\n' +
    '.\n' +
    'Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly',
  error_code: 'IC0503'
lastmjs commented 9 hours ago

canister: async_await functional

This is a similar error to the first one above...I wonder if they are the same error? This one looks easier to debug, so I say fix this one first.

  requestId: ArrayBuffer {
    [Uint8Contents]: <fc 7d 64 75 2f b9 db 6a dc 50 cb a4 a4 ee 84 70 80 cf e9 e0 24 38 64 15 6c 46 a4 7a 56 84 80 d5>,
    byteLength: 32
  },
  response: {
    ok: true,
    status: 200,
    statusText: 'OK',
    body: { status: 'replied', certificate: [Uint8Array] },
    headers: [ [Array], [Array], [Array], [Array] ]
  },
  reject_code: 5,
  reject_message: 'Error from Canister bkyz2-fmaaa-aaaaa-qaaaq-cai: Canister called `ic0.trap` with message: Panic occurred: already borrowed: BorrowMutError at src/build/experimental/commands/compile/wasm_binary/rust/experimental_canister_template/src/ic/call_raw.rs:46.\n' +
    'Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly',
  error_code: 'IC0503'
}