{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/1408","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/1408/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/1408/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/1408/events","html_url":"https://github.com/crystal-lang/crystal/issues/1408","id":105271244,"number":1408,"title":"Segfault: using generics","user":{"login":"Ragmaanir","id":113789,"avatar_url":"https://avatars.githubusercontent.com/u/113789?v=3","gravatar_id":"","url":"https://api.github.com/users/Ragmaanir","html_url":"https://github.com/Ragmaanir","followers_url":"https://api.github.com/users/Ragmaanir/followers","following_url":"https://api.github.com/users/Ragmaanir/following{/other_user}","gists_url":"https://api.github.com/users/Ragmaanir/gists{/gist_id}","starred_url":"https://api.github.com/users/Ragmaanir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ragmaanir/subscriptions","organizations_url":"https://api.github.com/users/Ragmaanir/orgs","repos_url":"https://api.github.com/users/Ragmaanir/repos","events_url":"https://api.github.com/users/Ragmaanir/events{/privacy}","received_events_url":"https://api.github.com/users/Ragmaanir/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/crystal-lang/crystal/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/crystal-lang/crystal/labels/compiler","name":"compiler","color":"fef2c0"},{"url":"https://api.github.com/repos/crystal-lang/crystal/labels/duplicate","name":"duplicate","color":"cccccc"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2015-09-07T22:02:29Z","updated_at":"2016-07-17T17:35:08Z","closed_at":"2015-09-08T00:18:38Z","body":"Hi, thank you for crystal. I am moving from ruby and scala to crystal because i think it is better than both of them. This is a segfault i stumbled upon (code abstracted from a project):\r\n\r\n```crystal\r\nrequire \"http/request\"\r\n\r\nclass Ctx # think \"Context\"\r\n  @req :: HTTP::Request\r\n  getter :request\r\n\r\n  def initialize(@request : HTTP::Request)\r\n  end\r\nend\r\n\r\nclass CCtx(T) < Ctx\r\n  def initialize(@original : T)\r\n    @request = @original.request\r\n  end\r\nend\r\n\r\nclass SCtx(T) < Ctx\r\n  def initialize(@original : T)\r\n    @request = @original.request\r\n  end\r\nend\r\n\r\nclass M # think \"Middleware\"\r\n  getter :successor\r\n  def initialize(@successor = nil)\r\n  end\r\n  def call(ctx : Ctx) : HTTP::Response\r\n    case s = successor\r\n    when M then s.call(ctx)\r\n    when Nil then HTTP::Response.not_found\r\n    else raise \"invalid param\"\r\n    end\r\n  end\r\nend\r\n\r\nclass CM < M\r\n  def call(ctx : T) : HTTP::Response\r\n    super(CCtx(T).new(ctx))\r\n  end\r\nend\r\n\r\nclass SM < M\r\n  def call(ctx : T) : HTTP::Response\r\n    super(SCtx(T).new(ctx)) # this line seems to cause the segfault. remove this one and uncomment the next line and it does not segfault.\r\n    #super(ctx)\r\n  end\r\nend\r\n\r\nm = CM.new(SM.new)\r\nputs \"a\"\r\nr = HTTP::Request.new(\"GET\", \"\")\r\nr.headers.merge!({\"Cookie\" => \"test=1;\"})\r\nctx = Ctx.new(r)\r\nputs \"b\"\r\nm.call(ctx)\r\nputs \"c\"\r\n```\r\n\r\n**version**: 0.7.7"},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/233193670","html_url":"https://github.com/crystal-lang/crystal/issues/1408#issuecomment-233193670","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/1408","id":233193670,"user":{"login":"waterlink","id":609046,"avatar_url":"https://avatars.githubusercontent.com/u/609046?v=3","gravatar_id":"","url":"https://api.github.com/users/waterlink","html_url":"https://github.com/waterlink","followers_url":"https://api.github.com/users/waterlink/followers","following_url":"https://api.github.com/users/waterlink/following{/other_user}","gists_url":"https://api.github.com/users/waterlink/gists{/gist_id}","starred_url":"https://api.github.com/users/waterlink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waterlink/subscriptions","organizations_url":"https://api.github.com/users/waterlink/orgs","repos_url":"https://api.github.com/users/waterlink/repos","events_url":"https://api.github.com/users/waterlink/events{/privacy}","received_events_url":"https://api.github.com/users/waterlink/received_events","type":"User","site_admin":false},"created_at":"2016-07-17T17:35:08Z","updated_at":"2016-07-17T17:35:08Z","body":"I will try to cleanly re-write the query mechanism in a separate snippet of code and reproduce the issue, so that we can look at possible solutions. Plus I will try out some of the solutions."}}
{"actor":{"display_login":"waterlink"}}