{"action":"closed","issue":{"url":"https://api.github.com/repos/npgsql/npgsql/issues/1381","repository_url":"https://api.github.com/repos/npgsql/npgsql","labels_url":"https://api.github.com/repos/npgsql/npgsql/issues/1381/labels{/name}","comments_url":"https://api.github.com/repos/npgsql/npgsql/issues/1381/comments","events_url":"https://api.github.com/repos/npgsql/npgsql/issues/1381/events","html_url":"https://github.com/npgsql/npgsql/issues/1381","id":195514168,"number":1381,"title":"EndOfStreamException when using a PostgisMultiPolygon containing a PostgisPolygon with a SRID","user":{"login":"bastien-hofmann","id":8101252,"avatar_url":"https://avatars.githubusercontent.com/u/8101252?v=3","gravatar_id":"","url":"https://api.github.com/users/bastien-hofmann","html_url":"https://github.com/bastien-hofmann","followers_url":"https://api.github.com/users/bastien-hofmann/followers","following_url":"https://api.github.com/users/bastien-hofmann/following{/other_user}","gists_url":"https://api.github.com/users/bastien-hofmann/gists{/gist_id}","starred_url":"https://api.github.com/users/bastien-hofmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastien-hofmann/subscriptions","organizations_url":"https://api.github.com/users/bastien-hofmann/orgs","repos_url":"https://api.github.com/users/bastien-hofmann/repos","events_url":"https://api.github.com/users/bastien-hofmann/events{/privacy}","received_events_url":"https://api.github.com/users/bastien-hofmann/received_events","type":"User","site_admin":false},"labels":[{"id":69978383,"url":"https://api.github.com/repos/npgsql/npgsql/labels/bug","name":"bug","color":"e11d21","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/npgsql/npgsql/milestones/38","html_url":"https://github.com/npgsql/npgsql/milestone/38","labels_url":"https://api.github.com/repos/npgsql/npgsql/milestones/38/labels","id":2145690,"number":38,"title":"3.1.10","description":"","creator":{"login":"roji","id":1862641,"avatar_url":"https://avatars.githubusercontent.com/u/1862641?v=3","gravatar_id":"","url":"https://api.github.com/users/roji","html_url":"https://github.com/roji","followers_url":"https://api.github.com/users/roji/followers","following_url":"https://api.github.com/users/roji/following{/other_user}","gists_url":"https://api.github.com/users/roji/gists{/gist_id}","starred_url":"https://api.github.com/users/roji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roji/subscriptions","organizations_url":"https://api.github.com/users/roji/orgs","repos_url":"https://api.github.com/users/roji/repos","events_url":"https://api.github.com/users/roji/events{/privacy}","received_events_url":"https://api.github.com/users/roji/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":3,"state":"open","created_at":"2016-11-19T08:12:52Z","updated_at":"2016-12-16T08:49:46Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2016-12-14T12:06:15Z","updated_at":"2016-12-16T08:49:46Z","closed_at":"2016-12-16T08:49:46Z","body":"Hello,\r\n\r\nI believe there is a problem with the way Npgsql calculates the size of data it needs to send when working with Postgis geometries. It includes the length for the SRID of sub geometries (for example a PostgisPolygon inside a PostgisMultiPolygon, both having the SRID set), but doesn't sent the PostgisPolygon's SRID in the payload.\r\nThis results in a EndOfStreamException.\r\n\r\nI believe this pull request includes a solution for this problem:\r\nhttps://github.com/npgsql/npgsql/pull/1235\r\nIt changes the GetLen method to this: GetLen(bool asSubGeometry) to ignore SRID size in sub geometries.\r\n\r\nBest regards\r\n\r\n### Steps to reproduce\r\n\r\nPlease find a test project attached.\r\n[EndOfStreamExceptionDemo.zip](https://github.com/npgsql/npgsql/files/651651/EndOfStreamExceptionDemo.zip)\r\n\r\nSimply setting the SRID of the PostgisPolygon triggers the exception, removing it solves it.\r\n\r\n### The issue\r\nNpgsql.NpgsqlException was unhandled\r\n  ErrorCode=-2147467259\r\n  HResult=-2147467259\r\n  Message=Exception while reading from stream\r\n  Source=Npgsql\r\n  StackTrace:\r\n       à Npgsql.ReadBuffer.Ensure(Int32 count, Boolean dontBreakOnTimeouts)\r\n       à Npgsql.NpgsqlConnector.DoReadMessage(DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage)\r\n       à Npgsql.NpgsqlConnector.ReadMessageWithPrepended(DataRowLoadingMode dataRowLoadingMode)\r\n       à Npgsql.NpgsqlConnector.ReadMessage(DataRowLoadingMode dataRowLoadingMode)\r\n       à Npgsql.NpgsqlConnector.ReadExpecting[T]()\r\n       à Npgsql.NpgsqlDataReader.NextResultInternal()\r\n       à Npgsql.NpgsqlDataReader.NextResult()\r\n       à Npgsql.NpgsqlCommand.Execute(CommandBehavior behavior)\r\n       à Npgsql.NpgsqlCommand.ExecuteNonQueryInternal()\r\n       à Npgsql.NpgsqlCommand.ExecuteNonQuery()\r\n       à EndOfStreamExceptionDemo.Program.Main(String[] args) dans C:\\Code\\Temp\\EndOfStreamExceptionDemo\\EndOfStreamExceptionDemo\\Program.cs:ligne 42\r\n       à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)\r\n       à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n       à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n       à System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n       à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n       à System.Threading.ThreadHelper.ThreadStart()\r\n  InnerException: \r\n       HResult=-2146232800\r\n       Message=Impossible de lire les données de la connexion de transport : Une connexion existante a dû être fermée par l’hôte distant.\r\n       Source=System\r\n       StackTrace:\r\n            à System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)\r\n            à Npgsql.ReadBuffer.Ensure(Int32 count, Boolean dontBreakOnTimeouts)\r\n       InnerException: \r\n            ErrorCode=10054\r\n            HResult=-2147467259\r\n            Message=Une connexion existante a dû être fermée par l’hôte distant\r\n            NativeErrorCode=10054\r\n            Source=System\r\n            StackTrace:\r\n                 à System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)\r\n                 à System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)\r\n            InnerException: \r\n\r\n\r\n### Further technical details\r\n\r\nNpgsql version: 3.1.9\r\nPostgreSQL version: 9.5.0\r\nOperating system: Windows 8.1\r\n"}}
{"actor":{"display_login":"roji"}}