Bug 43988 - Stack overflow in System.Text.Encoding.Default
Summary: Stack overflow in System.Text.Encoding.Default
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC Windows
: High major
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-09-04 15:22 UTC by cmp
Modified: 2017-05-11 19:07 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description cmp 2016-09-04 15:22:07 UTC
The issue happens in systems with "unusual" code page values (like 1256 - Arabic). It can be reproduced easily (without changing system language settings) by replacing GetACP() in g_get_charset with 1256 and running a simple program with Console.WriteLine("Hello world!");

Stack trace:
0x0000023BA33F369E mscorlib (System.Text.Encoding:get_Default+0x3E at encoding.cs:1460)
0x0000023BA3438D72 mscorlib (string:CreateString+0xC2 at String.cs:747)
0x0000023BA3438C4E mscorlib (string:CreateString+0xFE at String.cs:686)
0x0000023BA3438AFC mscorlib ((wrapper managed-to-managed) string:.ctor+0x3C)
0x0000023BA34385AA mscorlib (System.Reflection.AssemblyName:FillName+0x5A at AssemblyName.cs:469)
0x0000023BA3437FC1 mscorlib (System.Reflection.AssemblyName:Create+0xC1 at AssemblyName.cs:519)
0x0000023BA3437ABC mscorlib (System.Reflection.RuntimeAssembly:GetName+0x5C at MonoAssembly.cs:167)
0x0000023BA3437A14 mscorlib (System.Reflection.Assembly:GetName+0x34 at Assembly.cs:435)
0x0000023BA34375CE I18N (I18N.Common.Manager:Instantiate+0x1FE at Manager.cs:226)
0x0000023BA343438F I18N (I18N.Common.Manager:GetEncoding+0x6F at Manager.cs:94)
0x0000023BA3434556 I18N ((wrapper runtime-invoke) <Module>:runtime_invoke_object__this___int+0x136)
0x00007FF6DB4C1B9F MyApp.exe+0x171B9F (mono_jit_runtime_invoke+0x50F)
0x00007FF6DB495707 MyApp.exe+0x145707 (do_runtime_invoke+0x87)
0x00007FF6DB49D1F2 MyApp.exe+0x14D1F2 (mono_runtime_invoke_checked+0x62)
0x00007FF6DB49D7EB MyApp.exe+0x14D7EB (mono_runtime_try_invoke_array+0x3FB)
0x00007FF6DB49D16E MyApp.exe+0x14D16E (mono_runtime_invoke_array_checked+0x3E)
0x00007FF6DB4E0D64 MyApp.exe+0x190D64 (ves_icall_InternalInvoke+0x5C4)
0x0000023BA3419A68 mscorlib ((wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke+0xA8)
0x0000023BA3419023 mscorlib (System.Reflection.MonoMethod:Invoke+0xD3 at MonoMethod.cs:305)
0x0000023BA3415D6F mscorlib (System.RuntimeType:InvokeMember+0x137F at rttype.cs:5008)
0x0000023BA3413C5E mscorlib (System.Text.EncodingHelper:InvokeI18N+0x45E at EncodingHelper.cs:182)
0x0000023BA33F22E8 mscorlib (System.Text.Encoding:GetEncoding+0x668 at encoding.cs:552)
0x0000023BA33F3C41 mscorlib (System.Text.Encoding:GetEncoding+0x81 at encoding.cs:696)
0x0000023BA33F3806 mscorlib (System.Text.EncodingHelper:GetDefaultEncoding+0x76 at EncodingHelper.cs:85)
0x0000023BA33F373C mscorlib (System.Text.Encoding:CreateDefaultEncoding+0x2C at encoding.cs:1435)
0x0000023BA33F369E mscorlib (System.Text.Encoding:get_Default+0x3E at encoding.cs:1460)
0x0000023BA33F1F5A mscorlib (System.Text.Encoding:GetEncoding+0x2DA at encoding.cs:466)
0x0000023BA33F15BE mscorlib (System.Console:.cctor+0xBE at Console.cs:108)
Comment 1 Michael DeRoy 2017-05-02 13:31:24 UTC
We have also seen this bug in unity, with the same locale arabic (algeria)

>	mono-2.0-bdwgc.dll!GC_clear_stack_inner(void * arg, char * limit) Line 335	C
 	mono-2.0-bdwgc.dll!GC_clear_stack_inner(void * arg, char * limit) Line 344	C
 	mono-2.0-bdwgc.dll!GC_clear_stack(void * arg) Line 389	C
 	mono-2.0-bdwgc.dll!GC_malloc(unsigned __int64 lb) Line 274	C
 	mono-2.0-bdwgc.dll!mono_gc_alloc_vector(MonoVTable * vtable, unsigned __int64 size, unsigned __int64 max_length) Line 695	C
 	mono-2.0-bdwgc.dll!mono_array_new_specific_checked(MonoVTable * vtable, unsigned __int64 n, _MonoError * error) Line 5923	C
 	mono-2.0-bdwgc.dll!ves_icall_array_new_specific(MonoVTable * vtable, unsigned __int64 n) Line 5937	C
 	0x0000023a99e0f300 "[mscorlib.dll] (wrapper managed-to-native) object:__icall_wrapper_ves_icall_array_new_specific (intptr,int) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e91a20 "[mscorlib.dll] System.RuntimeType/ListBuilder`1<T_REF>:Add (T_REF) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99c4c940 "[mscorlib.dll] System.RuntimeType:GetMethodCandidates (string,System.Reflection.BindingFlags,System.Reflection.CallingConventions,System.Type[],bool) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e0f8b0 "[mscorlib.dll] System.RuntimeType:GetMember (string,System.Reflection.MemberTypes,System.Reflection.BindingFlags) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a97316530 "[mscorlib.dll] System.RuntimeType:InvokeMember (string,System.Reflection.BindingFlags,System.Reflection.Binder,object,object[],System.Reflection.ParameterModifier[],System.Globalization.CultureInfo,st...
 	0x0000023a973343c0 "[mscorlib.dll] System.Text.EncodingHelper:InvokeI18N (string,object[]) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1b3e0 "[mscorlib.dll] System.Text.Encoding:GetEncoding (int) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e903a0 "[mscorlib.dll] System.Text.Encoding:GetEncoding (string) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e8fcc0 "[mscorlib.dll] System.Text.EncodingHelper:GetDefaultEncoding () Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e8fe00 "[mscorlib.dll] System.Text.Encoding:CreateDefaultEncoding () Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1b470 "[mscorlib.dll] System.Text.Encoding:get_Default () Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99ed3a90 "[mscorlib.dll] string:CreateString (sbyte*,int,int,System.Text.Encoding) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1bb30 "[mscorlib.dll] string:CreateString (sbyte*) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e91200 "[mscorlib.dll] (wrapper managed-to-managed) string:.ctor (sbyte*) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99ccf050 "[mscorlib.dll] System.Reflection.AssemblyName:FillName (Mono.MonoAssemblyName*,string,bool,bool,bool) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99cce690 "[mscorlib.dll] System.Reflection.AssemblyName:Create (System.Reflection.Assembly,bool) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e90120 "[mscorlib.dll] System.Reflection.RuntimeAssembly:GetName (bool) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1ca60 "[mscorlib.dll] System.Reflection.Assembly:GetName () Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1b080 "[I18N.dll] I18N.Common.Manager:Instantiate (string) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1caf0 "[I18N.dll] I18N.Common.Manager:GetEncoding (int) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e104e0 "[I18N.dll] (wrapper runtime-invoke) <Module>:runtime_invoke_object__this___int (object,intptr,intptr,intptr) Line <UNKNOWN> File <UNKNOWN>"
 	mono-2.0-bdwgc.dll!mono_jit_runtime_invoke(_MonoMethod * method, void * obj, void * * params, _MonoObject * * exc, _MonoError * error) Line 2665	C
 	mono-2.0-bdwgc.dll!do_runtime_invoke(_MonoMethod * method, void * obj, void * * params, _MonoObject * * exc, _MonoError * error) Line 2813	C
 	mono-2.0-bdwgc.dll!mono_runtime_invoke_checked(_MonoMethod * method, void * obj, void * * params, _MonoError * error) Line 2972	C
 	mono-2.0-bdwgc.dll!mono_runtime_try_invoke_array(_MonoMethod * method, void * obj, _MonoArray * params, _MonoObject * * exc, _MonoError * error) Line 5076	C
 	mono-2.0-bdwgc.dll!mono_runtime_invoke_array_checked(_MonoMethod * method, void * obj, _MonoArray * params, _MonoError * error) Line 4956	C
 	mono-2.0-bdwgc.dll!ves_icall_InternalInvoke(_MonoReflectionMethod * method, _MonoObject * this_arg, _MonoArray * params, _MonoException * * exc) Line 3266	C
 	0x0000023a99cda950 "[mscorlib.dll] (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99cda850 "[mscorlib.dll] System.Reflection.MonoMethod:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a97317110 "[mscorlib.dll] System.RuntimeType:InvokeMember (string,System.Reflection.BindingFlags,System.Reflection.Binder,object,object[],System.Reflection.ParameterModifier[],System.Globalization.CultureInfo,st...
 	0x0000023a99ed3930 "[mscorlib.dll] System.Text.EncodingHelper:InvokeI18N (string,object[]) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1cb80 "[mscorlib.dll] System.Text.Encoding:GetEncoding (int) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e8fc20 "[mscorlib.dll] System.Text.Encoding:GetEncoding (string) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e92100 "[mscorlib.dll] System.Text.EncodingHelper:GetDefaultEncoding () Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e90440 "[mscorlib.dll] System.Text.Encoding:CreateDefaultEncoding () Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1c790 "[mscorlib.dll] System.Text.Encoding:get_Default () Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99ed2f90 "[mscorlib.dll] string:CreateString (sbyte*,int,int,System.Text.Encoding) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1c310 "[mscorlib.dll] string:CreateString (sbyte*) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e91de0 "[mscorlib.dll] (wrapper managed-to-managed) string:.ctor (sbyte*) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99ccf110 "[mscorlib.dll] System.Reflection.AssemblyName:FillName (Mono.MonoAssemblyName*,string,bool,bool,bool) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99ccf7d0 "[mscorlib.dll] System.Reflection.AssemblyName:Create (System.Reflection.Assembly,bool) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e91980 "[mscorlib.dll] System.Reflection.RuntimeAssembly:GetName (bool) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1b230 "[mscorlib.dll] System.Reflection.Assembly:GetName () Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1c3a0 "[I18N.dll] I18N.Common.Manager:Instantiate (string) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e1c670 "[I18N.dll] I18N.Common.Manager:GetEncoding (int) Line <UNKNOWN> File <UNKNOWN>"
 	0x0000023a99e0fb20 "[I18N.dll] (wrapper runtime-invoke) <Module>:runtime_invoke_object__this___int (object,intptr,intptr,intptr) Line <UNKNOWN> File <UNKNOWN>"
Comment 2 Miguel de Icaza [MSFT] 2017-05-02 17:26:00 UTC
This looks like a regression.
Comment 3 Jonathan Chambers 2017-05-11 13:34:31 UTC
Proposed fix here: https://github.com/mono/mono/pull/4830
Comment 4 Jonathan Chambers 2017-05-11 17:50:39 UTC
Merged to master here: https://github.com/mono/mono/commit/053868c17bd23e065c9d73d8f470b0d290d12714
Comment 5 Marek Safar 2017-05-11 19:07:17 UTC
Fixed in master and 2017-04 branch