Hi

I am fine with this.

On 10/06/20 06:11 -0600, Thomas Frohwein wrote:
> Hi,
> 
> This is an addition to prior compatibility enhancement for lang/mono
> [1][2]. I encountered the exceptions being triggered with Shenzhen I/O
> and Burning Knight, and the patch below resolves the problem without
> creating attributable issues on my testing.
> 
> Like before, this keeps the compatibility fix behind MONO_FORCE_COMPAT
> environment variable, and it is not intended for regular use as
> undefined behavior may be triggered.
> 
> Keeping the 'GetEnvironmentVariable("MONO_FORCE_COMPAT")' inside the
> if-statements will ensure that performance won't be affected _unless_
> the exception would be triggered anyway.
> 
> The first hunk of the second patch (List.cs) moves the env var check
> into the if block to reduce the risk of this affecting performance
> during regular use. Note that I haven't noticed any significant
> performance impact from any of this.
> 
> CC maintainer
> 
> ok?
> 
> [1] https://marc.info/?l=openbsd-ports&m=157013038104300&q=mbox
> [2] https://marc.info/?l=openbsd-ports-cvs&m=157349190600488&q=mbox
> 
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/lang/mono/Makefile,v
> retrieving revision 1.136
> diff -u -p -r1.136 Makefile
> --- Makefile  14 Apr 2020 14:43:21 -0000      1.136
> +++ Makefile  10 Jun 2020 06:32:28 -0000
> @@ -5,7 +5,7 @@ USE_WXNEEDED= Yes
>  COMMENT=     cross platform, open source .NET developement framework
>  
>  V=           6.8.0.105
> -REVISION=    1
> +REVISION=    2
>  
>  DISTNAME=    mono-${V}
>  
> Index: 
> patches/patch-external_corefx_src_Common_src_CoreLib_System_Collections_Generic_Dictionary_cs
> ===================================================================
> RCS file: 
> patches/patch-external_corefx_src_Common_src_CoreLib_System_Collections_Generic_Dictionary_cs
> diff -N 
> patches/patch-external_corefx_src_Common_src_CoreLib_System_Collections_Generic_Dictionary_cs
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ 
> patches/patch-external_corefx_src_Common_src_CoreLib_System_Collections_Generic_Dictionary_cs
>      10 Jun 2020 06:32:28 -0000
> @@ -0,0 +1,17 @@
> +$OpenBSD$
> +
> +More MONO_FORCE_COMPAT where it may be needed.
> +
> +Index: 
> external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs
> +--- 
> external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs.orig
> ++++ 
> external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs
> +@@ -1610,7 +1610,8 @@ namespace System.Collections.Generic
> +                 {
> +                     if (_version != _dictionary._version)
> +                     {
> +-                        
> ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
> ++                        if (Environment.GetEnvironmentVariable 
> ("MONO_FORCE_COMPAT") == null)
> ++                            
> ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
> +                     }
> + 
> +                     while ((uint)_index < (uint)_dictionary._count)
> Index: 
> patches/patch-external_corefx_src_Common_src_CoreLib_System_Collections_Generic_List_cs
> ===================================================================
> RCS file: 
> /cvs/ports/lang/mono/patches/patch-external_corefx_src_Common_src_CoreLib_System_Collections_Generic_List_cs,v
> retrieving revision 1.1
> diff -u -p -r1.1 
> patch-external_corefx_src_Common_src_CoreLib_System_Collections_Generic_List_cs
> --- 
> patches/patch-external_corefx_src_Common_src_CoreLib_System_Collections_Generic_List_cs
>    11 Nov 2019 17:05:02 -0000      1.1
> +++ 
> patches/patch-external_corefx_src_Common_src_CoreLib_System_Collections_Generic_List_cs
>    10 Jun 2020 06:32:28 -0000
> @@ -8,17 +8,25 @@ well-defined cases.
>  Index: 
> external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs
>  --- 
> external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs.orig
>  +++ external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs
> -@@ -578,8 +578,11 @@ namespace System.Collections.Generic
> -                 action(_items[i]);
> +@@ -579,7 +579,10 @@ namespace System.Collections.Generic
>               }
>   
> --            if (version != _version)
> +             if (version != _version)
>  -                
> ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
> -+            if (Environment.GetEnvironmentVariable ("MONO_FORCE_COMPAT") == 
> null)
>  +            {
> -+                if (version != _version)
> ++                if (Environment.GetEnvironmentVariable 
> ("MONO_FORCE_COMPAT") == null)
>  +                    
> ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
>  +            }
>           }
>   
>           // Returns an enumerator for this list with the given
> +@@ -1160,7 +1163,8 @@ namespace System.Collections.Generic
> +             {
> +                 if (_version != _list._version)
> +                 {
> +-                    
> ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
> ++                    if (Environment.GetEnvironmentVariable 
> ("MONO_FORCE_COMPAT") == null)
> ++                        
> ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
> +                 }
> + 
> +                 _index = _list._size + 1;

-- 
Regards,
Robert Nagy

Reply via email to