{"action":"created","issue":{"url":"https://api.github.com/repos/EOSIO/eos/issues/4394","repository_url":"https://api.github.com/repos/EOSIO/eos","labels_url":"https://api.github.com/repos/EOSIO/eos/issues/4394/labels{/name}","comments_url":"https://api.github.com/repos/EOSIO/eos/issues/4394/comments","events_url":"https://api.github.com/repos/EOSIO/eos/issues/4394/events","html_url":"https://github.com/EOSIO/eos/issues/4394","id":336554848,"node_id":"MDU6SXNzdWUzMzY1NTQ4NDg=","number":4394,"title":"how do deal with assertion failure with message: read","user":{"login":"breadbread1984","id":1930282,"node_id":"MDQ6VXNlcjE5MzAyODI=","avatar_url":"https://avatars0.githubusercontent.com/u/1930282?v=4","gravatar_id":"","url":"https://api.github.com/users/breadbread1984","html_url":"https://github.com/breadbread1984","followers_url":"https://api.github.com/users/breadbread1984/followers","following_url":"https://api.github.com/users/breadbread1984/following{/other_user}","gists_url":"https://api.github.com/users/breadbread1984/gists{/gist_id}","starred_url":"https://api.github.com/users/breadbread1984/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/breadbread1984/subscriptions","organizations_url":"https://api.github.com/users/breadbread1984/orgs","repos_url":"https://api.github.com/users/breadbread1984/repos","events_url":"https://api.github.com/users/breadbread1984/events{/privacy}","received_events_url":"https://api.github.com/users/breadbread1984/received_events","type":"User","site_admin":false},"labels":[{"id":936623288,"node_id":"MDU6TGFiZWw5MzY2MjMyODg=","url":"https://api.github.com/repos/EOSIO/eos/labels/Support","name":"Support","color":"7d7ad6","default":false}],"state":"closed","locked":false,"assignee":{"login":"sergmetelin","id":2141500,"node_id":"MDQ6VXNlcjIxNDE1MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/2141500?v=4","gravatar_id":"","url":"https://api.github.com/users/sergmetelin","html_url":"https://github.com/sergmetelin","followers_url":"https://api.github.com/users/sergmetelin/followers","following_url":"https://api.github.com/users/sergmetelin/following{/other_user}","gists_url":"https://api.github.com/users/sergmetelin/gists{/gist_id}","starred_url":"https://api.github.com/users/sergmetelin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergmetelin/subscriptions","organizations_url":"https://api.github.com/users/sergmetelin/orgs","repos_url":"https://api.github.com/users/sergmetelin/repos","events_url":"https://api.github.com/users/sergmetelin/events{/privacy}","received_events_url":"https://api.github.com/users/sergmetelin/received_events","type":"User","site_admin":false},"assignees":[{"login":"sergmetelin","id":2141500,"node_id":"MDQ6VXNlcjIxNDE1MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/2141500?v=4","gravatar_id":"","url":"https://api.github.com/users/sergmetelin","html_url":"https://github.com/sergmetelin","followers_url":"https://api.github.com/users/sergmetelin/followers","following_url":"https://api.github.com/users/sergmetelin/following{/other_user}","gists_url":"https://api.github.com/users/sergmetelin/gists{/gist_id}","starred_url":"https://api.github.com/users/sergmetelin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergmetelin/subscriptions","organizations_url":"https://api.github.com/users/sergmetelin/orgs","repos_url":"https://api.github.com/users/sergmetelin/repos","events_url":"https://api.github.com/users/sergmetelin/events{/privacy}","received_events_url":"https://api.github.com/users/sergmetelin/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-06-28T10:00:57Z","updated_at":"2018-08-29T05:10:36Z","closed_at":"2018-07-05T03:32:38Z","author_association":"NONE","body":"My contract action causes error message\r\n\r\n>  assertion failure with message: read\r\n\r\nMy action code  is here\r\n\r\n```c++\r\nvoid GeneMelee::buy(account_name buyer,uint64_t sale_key,asset price)\r\n{\r\n\t//check existence\r\n\tsaletable sales(_self,_self);\r\n\tauto which = sales.find(sale_key);\r\n\teosio_assert(sales.end() != which,\"no such item on sale\");\r\n\t//check whether the transferred quantity is over the price\r\n\teosio_assert(price.symbol == which->price.symbol,\"the payment is not the seller's required currency!\");\r\n\teosio_assert(price.amount >= which->price.amount,\"the payment is not enough to buy the item!\");\r\n\taction(\r\n\t\tpermission_level{_self,N(active)},\r\n\t\tN(eosio.token),N(transfer),\r\n\t\tstd::make_tuple(_self,which->player,price,\"payment from buyer\")\r\n\t).send();\r\n\t//hand over item\r\n\tswitch(which->type) {\r\n\t\tcase static_cast<int>(ForSale::ELF):\r\n\t\t\t{\r\n\t\t\t\telftable seller_elfs(_self,which->player);\r\n\t\t\t\tauto which_elf = seller_elfs.find(which->item_key);\r\n\t\t\t\teosio_assert(seller_elfs.end() != which_elf,\"seller don't have the elf for sale\");\r\n\t\t\t\telftable buyer_elfs(_self,buyer);\r\n\t\t\t\tbuyer_elfs.emplace(_self,[&](auto & elf){\r\n\t\t\t\t\telf.elf_key = buyer_elfs.available_primary_key();\r\n\t\t\t\t\telf.genre = which_elf->genre;\r\n\t\t\t\t\telf.level = which_elf->level;\r\n\t\t\t\t\telf.appearance = which_elf->appearance;\r\n\t\t\t\t\telf.dna = which_elf->dna;\r\n\t\t\t\t\telf.capabilities = which_elf->capabilities;\r\n\t\t\t\t\telf.last_feed_datetime = which_elf->last_feed_datetime;\r\n\t\t\t\t\telf.feed_interval = which_elf->feed_interval;\r\n\t\t\t\t\telf.bgr = which_elf->bgr;\r\n\t\t\t\t});\r\n\t\t\t\tseller_elfs.erase(which_elf);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase static_cast<int>(ForSale::GENE):\r\n\t\t\t{\r\n\t\t\t\tgenetable seller_genes(_self,which->player);\r\n\t\t\t\tauto which_gene = seller_genes.find(which->item_key);\r\n\t\t\t\teosio_assert(seller_genes.end() != which_gene,\"seller don't have the gene for sale\");\r\n\t\t\t\tgenetable buyer_genes(_self,buyer);\r\n\t\t\t\tbuyer_genes.emplace(_self,[&](auto & gene) {\r\n\t\t\t\t\tgene.gene_key = buyer_genes.available_primary_key();\r\n\t\t\t\t\tgene.segment_id = which_gene->segment_id;\r\n\t\t\t\t\tgene.delta_appearance = which_gene->delta_appearance;\r\n\t\t\t\t\tgene.delta_capabilities = which_gene->delta_capabilities;\r\n\t\t\t\t\tgene.delta_bgr = which_gene->delta_bgr;\r\n\t\t\t\t});\r\n\t\t\t\tseller_genes.erase(which_gene);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\teosio_assert(0,\"unknown type of item!\");\r\n\t}\r\n\t//remove from saling table\r\n\tsales.erase(which);\r\n}\r\n```\r\n\r\nwhich part of the code could cause the error message? One thing I can't understand is that I added eosio_assert(0,\"here\"); to the last line of the action. when I call the action, my assertion can always be triggered. it seems the error occurs after the action is called."},"comment":{"url":"https://api.github.com/repos/EOSIO/eos/issues/comments/416826183","html_url":"https://github.com/EOSIO/eos/issues/4394#issuecomment-416826183","issue_url":"https://api.github.com/repos/EOSIO/eos/issues/4394","id":416826183,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjgyNjE4Mw==","user":{"login":"spartucus","id":6071887,"node_id":"MDQ6VXNlcjYwNzE4ODc=","avatar_url":"https://avatars1.githubusercontent.com/u/6071887?v=4","gravatar_id":"","url":"https://api.github.com/users/spartucus","html_url":"https://github.com/spartucus","followers_url":"https://api.github.com/users/spartucus/followers","following_url":"https://api.github.com/users/spartucus/following{/other_user}","gists_url":"https://api.github.com/users/spartucus/gists{/gist_id}","starred_url":"https://api.github.com/users/spartucus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spartucus/subscriptions","organizations_url":"https://api.github.com/users/spartucus/orgs","repos_url":"https://api.github.com/users/spartucus/repos","events_url":"https://api.github.com/users/spartucus/events{/privacy}","received_events_url":"https://api.github.com/users/spartucus/received_events","type":"User","site_admin":false},"created_at":"2018-08-29T05:10:36Z","updated_at":"2018-08-29T05:10:36Z","author_association":"CONTRIBUTOR","body":"So \r\n```\r\naction(\r\n\t\tpermission_level{_self,N(active)},\r\n\t\tN(eosio.token),N(transfer),\r\n\t\tstd::make_tuple(_self,which->player,price,\"payment from buyer\")\r\n\t).send();\r\n```\r\nfails and \r\n```\r\naction(\r\n\t\tpermission_level{_self,N(active)},\r\n\t\tN(eosio.token),N(transfer),\r\n\t\tstd::make_tuple(_self,which->player,price,std::string(\"payment from buyer\"))\r\n\t).send();\r\n```\r\nsucceed?\r\nI think it's a bug.  And there's someone met the same issue. see [here](https://eosio.stackexchange.com/questions/1224/inline-transfer-causes-error#comment998_1229)"}}
{"actor":{"display_login":"spartucus"}}