{"action":"created","issue":{"url":"https://api.github.com/repos/actix/actix-web/issues/332","repository_url":"https://api.github.com/repos/actix/actix-web","labels_url":"https://api.github.com/repos/actix/actix-web/issues/332/labels{/name}","comments_url":"https://api.github.com/repos/actix/actix-web/issues/332/comments","events_url":"https://api.github.com/repos/actix/actix-web/issues/332/events","html_url":"https://github.com/actix/actix-web/issues/332","id":333865545,"node_id":"MDU6SXNzdWUzMzM4NjU1NDU=","number":332,"title":"SharedHttpInnerMessage has UB","user":{"login":"mitsuhiko","id":7396,"node_id":"MDQ6VXNlcjczOTY=","avatar_url":"https://avatars1.githubusercontent.com/u/7396?v=4","gravatar_id":"","url":"https://api.github.com/users/mitsuhiko","html_url":"https://github.com/mitsuhiko","followers_url":"https://api.github.com/users/mitsuhiko/followers","following_url":"https://api.github.com/users/mitsuhiko/following{/other_user}","gists_url":"https://api.github.com/users/mitsuhiko/gists{/gist_id}","starred_url":"https://api.github.com/users/mitsuhiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitsuhiko/subscriptions","organizations_url":"https://api.github.com/users/mitsuhiko/orgs","repos_url":"https://api.github.com/users/mitsuhiko/repos","events_url":"https://api.github.com/users/mitsuhiko/events{/privacy}","received_events_url":"https://api.github.com/users/mitsuhiko/received_events","type":"User","site_admin":false},"labels":[{"id":969863010,"node_id":"MDU6TGFiZWw5Njk4NjMwMTA=","url":"https://api.github.com/repos/actix/actix-web/labels/unsafe","name":"unsafe","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-06-19T22:46:10Z","updated_at":"2018-06-21T22:43:54Z","closed_at":null,"author_association":"MEMBER","body":"Currently the `SharedHttpInnerMessage` has a const to mut cast which is quite unsafe and UB:\r\n\r\nhttps://github.com/actix/actix-web/blob/2f917f37000a1ec72250aa5ec087df00f07e7538/src/server/helpers.rs#L77-L81\r\n\r\nThis needs to use `UnsafeCell` at the very last but I'm not even sure if this is safe in general as you can clone the Rc."},"comment":{"url":"https://api.github.com/repos/actix/actix-web/issues/comments/399266184","html_url":"https://github.com/actix/actix-web/issues/332#issuecomment-399266184","issue_url":"https://api.github.com/repos/actix/actix-web/issues/332","id":399266184,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTI2NjE4NA==","user":{"login":"ZerothLaw","id":186607,"node_id":"MDQ6VXNlcjE4NjYwNw==","avatar_url":"https://avatars0.githubusercontent.com/u/186607?v=4","gravatar_id":"","url":"https://api.github.com/users/ZerothLaw","html_url":"https://github.com/ZerothLaw","followers_url":"https://api.github.com/users/ZerothLaw/followers","following_url":"https://api.github.com/users/ZerothLaw/following{/other_user}","gists_url":"https://api.github.com/users/ZerothLaw/gists{/gist_id}","starred_url":"https://api.github.com/users/ZerothLaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZerothLaw/subscriptions","organizations_url":"https://api.github.com/users/ZerothLaw/orgs","repos_url":"https://api.github.com/users/ZerothLaw/repos","events_url":"https://api.github.com/users/ZerothLaw/events{/privacy}","received_events_url":"https://api.github.com/users/ZerothLaw/received_events","type":"User","site_admin":false},"created_at":"2018-06-21T22:43:54Z","updated_at":"2018-06-21T22:43:54Z","author_association":"NONE","body":"If I might make a suggestion - use a view and transaction pattern. \r\n\r\nWhen the middleware \"modifies\" the request, what really happens internally is a Transaction is made that tracks the change. \r\n\r\nThen at the end, create a view of the resulting data. \r\n\r\na short pseudo-code example:\r\n```\r\nclass Table;\r\nt = Table(\"table_name\");\r\nt.add_row(Row(column1 = \"column_1\", column2 = \"column2\"...));\r\nt.add_row(Row(column1 = \"column_a\", column2 = \"columnb\"...));\r\nt.remove_row(index=0);\r\n```\r\nInternally, its a vector or list of Transactions that record the action taken (Remove/Add) for example and the relevant data:\r\n```\r\nself.transactions = [Transaction(Add, data=&Row), Transaction(Add, data=&Row), Transaction(Remove, data=(index=0))]\r\n```\r\nIf you were to iter through the rows through the table, the table would only offer the second row, because you removed the first one. \r\n\r\nThis lets the underlying data be immutable (relevant sometimes for web apis, such as taking a hash of the request that was sent vs the request as modified by some middleware), while still allowing mutability. \r\n\r\nThere may be some performance hits, but it seems to satisfy all the needs Actix has - support middleware and support conformant and safe Rust code. \r\n"}}
{"actor":{"display_login":"ZerothLaw"}}