-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON Serializer ArgumentOutOfRangeException #528
Comments
I would also note - this problem goes away if we wrap the return in ToOptimizedResult, and also the Serializer performance on Mono has gone from great to horrendous as of this problem. The problem did not (appear) to begin after any ServiceStack, Mono/Xamarin, or MacOS updates specifically. |
Can you show what is the content of I used following code for generating resulting string array: public object Any(logRequest request)
{
string[] s = new string[25];
for (int i = 0; i < s.Length; i++) {
s[i] = "INFO " + i.ToString();
}
return s.ToList();
} |
sure, s would generally be fairly large, its log4net log tail, like attached And come to think about it, the other services that are affected generally have fairly large payloads (sometimes a MB or more) |
I still can't reproduce it with this file. I also tried to create file from this log with 30Mb length, but it returns without issues. public object Any(logRequest request)
{
string s = File.ReadAllText ("log.txt");
return s.Split('\n').ToList();
} But after looking into mono sources I think I found what can raise the exception. This line does not allow to pass empty buffer, so I fix it in this commit. This fix will be available on MyGet as soon as we finish migrating CI and ServiceStack projects to VS 2017 format. |
@CampsiteHelper we pushed latest changes to MyGet, can you check does this fix resolve the issue? |
As this should be fixed, I close it. If issue is still exists feel free to reopen it again. |
DTO:
Service:
Call:
http://127.0.0.1:8081/api/log/25?format=json
(Note, xml or html do not have the same issue)
Result:
....(most of the appropriate JSON response.....INFO 2017-04-06 11:35:58,026 3571ms Util getRoles - Got 1 groups","DEBUG 2017-04-06 11:35:58,029 3574ms Util OnAuthenticated - Loaded user upon authentication","{"ResponseStatus":{"ErrorCode":"ArgumentOutOfRangeException","Message":"Specified argument was out of the range of valid values.\nParameter name: offset","StackTrace":" at System.Web.HttpResponseStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00031] in /private/tmp/source-mono-4.8.0/bockbuild-mono-4.8.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web/HttpResponseStream.cs:459 \n at ServiceStack.Text.DirectStreamWriter.Write (System.String s) [0x00034] in <5d202dc8fb8f479ba5bbea3e08634e28>:0 \n at ServiceStack.Text.Json.JsonUtils.WriteString (System.IO.TextWriter writer, System.String value) [0x0002c] in <5d202dc8fb8f479ba5bbea3e08634e28>:0 \n at ServiceStack.Text.Json.JsonTypeSerializer.WriteString (System.IO.TextWriter writer, System.String value) [0x00000] in <5d202dc8fb8f479ba5bbea3e08634e28>:0 \n at ServiceStack.Text.Common.WriteLists.WriteListString (ServiceStack.Text.Common.ITypeSerializer serializer, System.IO.TextWriter writer, System.Collections.Generic.List
1[T] list) [0x00023] in <5d202dc8fb8f479ba5bbea3e08634e28>:0 \n at ServiceStack.Text.Common.WriteLists.WriteListString (ServiceStack.Text.Common.ITypeSerializer serializer, System.IO.TextWriter writer, System.Object list) [0x00000] in <5d202dc8fb8f479ba5bbea3e08634e28>:0 \n at ServiceStack.Text.Common.WriteLists
2+<>c[T,TSerializer].b__5_0 (System.IO.TextWriter w, System.Object x) [0x00000] in <5d202dc8fb8f479ba5bbea3e08634e28>:0 \n at ServiceStack.Text.JsonSerializer.SerializeToStream (System.Object value, System.Type type, System.IO.Stream stream) [0x00012] in <5d202dc8fb8f479ba5bbea3e08634e28>:0 \n at ServiceStack.Text.JsonSerializer.SerializeToStream[T] (T value, System.IO.Stream stream) [0x00037] in <5d202dc8fb8f479ba5bbea3e08634e28>:0 \n at ServiceStack.Serialization.JsonDataContractSerializer.SerializeToStream[T] (T obj, System.IO.Stream stream) [0x00050] in :0 \n at ServiceStack.Host.ContentTypes+<>c.b__21_1 (ServiceStack.Web.IRequest r, System.Object o, System.IO.Stream s) [0x00000] in :0 \n at ServiceStack.Host.ContentTypes+<>c__DisplayClass20_0.b__0 (ServiceStack.Web.IRequest httpReq, System.Object dto, ServiceStack.Web.IResponse httpRes) [0x0000e] in :0 \n at ServiceStack.HttpResponseExtensionsInternal.WriteToResponse (ServiceStack.Web.IResponse response, System.Object result, ServiceStack.Web.ResponseSerializerDelegate defaultAction, ServiceStack.Web.IRequest request, System.Byte[] bodyPrefix, System.Byte[] bodySuffix) [0x003f0] in :0 ","Errors":[{"ErrorCode":"ArgumentOutOfRangeException","FieldName":"offset","Message":"Specified argument was out of the range of valid values.\n"}]}}The text was updated successfully, but these errors were encountered: