{"action":"closed","issue":{"url":"https://api.github.com/repos/WebAssembly/wabt/issues/233","repository_url":"https://api.github.com/repos/WebAssembly/wabt","labels_url":"https://api.github.com/repos/WebAssembly/wabt/issues/233/labels{/name}","comments_url":"https://api.github.com/repos/WebAssembly/wabt/issues/233/comments","events_url":"https://api.github.com/repos/WebAssembly/wabt/issues/233/events","html_url":"https://github.com/WebAssembly/wabt/issues/233","id":193262454,"number":233,"title":"Error message isn't printed due to invalid conversions through void*","user":{"login":"sunfishcode","id":4503403,"avatar_url":"https://avatars.githubusercontent.com/u/4503403?v=3","gravatar_id":"","url":"https://api.github.com/users/sunfishcode","html_url":"https://github.com/sunfishcode","followers_url":"https://api.github.com/users/sunfishcode/followers","following_url":"https://api.github.com/users/sunfishcode/following{/other_user}","gists_url":"https://api.github.com/users/sunfishcode/gists{/gist_id}","starred_url":"https://api.github.com/users/sunfishcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunfishcode/subscriptions","organizations_url":"https://api.github.com/users/sunfishcode/orgs","repos_url":"https://api.github.com/users/sunfishcode/repos","events_url":"https://api.github.com/users/sunfishcode/events{/privacy}","received_events_url":"https://api.github.com/users/sunfishcode/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-03T03:29:09Z","updated_at":"2016-12-05T15:13:22Z","closed_at":"2016-12-05T15:13:22Z","body":"I'm running wasmdump on what I believe is a malformed binary:\r\n\r\n```\r\n/Projects/wabt$ hexdump -C x.o\r\n00000000  00 61 73 6d 0d 00 00 00  01 84 80 80 80 00 01 60  |.asm...........`|\r\n00000010  00 00 02 90 80 80 80 00  01 03 65 6e 76 09 73 6f  |..........env.so|\r\n00000020  6d 65 74 68 69 6e 67 03  03 82 80 80 80 00 01 00  |mething.........|\r\n00000030  04 84 80 80 80 00 01 70  00 00 05 83 80 80 80 00  |.......p........|\r\n00000040  01 00 00 06 81 80 80 80  00 00 07 81 80 80 80 00  |................|\r\n00000050  00 09 86 80 80 80 00 01  00 41 00 0b 00 0a 8b 80  |.........A......|\r\n00000060  80 80 00 01 09 00 10 ff  ff ff ff 0f 0f 0b 0b 86  |................|\r\n00000070  80 80 80 00 01 00 41 00  0b 00                    |......A...|\r\n0000007a\r\n```\r\nHowever, wasmdump doesn't print an error message, though it does exit with a non-zero status:\r\n```\r\n/Projects/wabt$ wasmdump -h x.o\r\nx.o:\tfile format wasm 0x00000d\r\n\r\nSections:\r\n     TYPE start=0x0000000e end=0x00000012 (size=0x00000004) count: 1\r\n   IMPORT start=0x00000018 end=0x00000028 (size=0x00000010) count: 1\r\n/Projects/wabt$ echo $?\r\n1\r\n```\r\n\r\nThis gdb session shows a strange thing happening at the point where what should have been the error message is being printed:\r\n```\r\n0x0000000000413945 in wasm_default_binary_error_callback (offset=40, \r\n    error=0x7fffffffcee0 \"unable to read i32 leb128: global type\", user_data=0x7fffffffdab0)\r\n    at /Projects/wabt/src/common.c:194\r\n194\t  print_error_header(out, info);\r\n(gdb) p info\r\n$25 = (WasmDefaultErrorHandlerInfo *) 0x7fffffffdab0\r\n(gdb) up 7\r\n#8  0x0000000000402a45 in wasm_read_binary_objdump (allocator=0x421ac0 <g_wasm_libc_allocator>, \r\n    data=0x424260 \"\", size=122, options=0x422d28 <s_objdump_options>)\r\n    at /Projects/wabt/src/binary-reader-objdump.c:671\r\n671\t  return wasm_read_binary(allocator, data, size, &reader, 1, &read_options);\r\n(gdb) p &context\r\n$26 = (Context *) 0x7fffffffdab0\r\n```\r\n\r\nNote that the `Context` address is the same as the WasmDefaultErrorHandlerInfo address. But Context is not a compatible struct with WasmDefaultErrorHandlerInfo. The data is a Context, but it's being read as a WasmDefaultErrorHandlerInfo, so the FILE* being read is bogus, and fprintf on my system in this instance appears to be just ignoring the invalid data and printing nothing.\r\n"}}
{"actor":{"display_login":"sunfishcode"}}