We use the docker image ‘unityci/editor :ubuntu-2020.3.5f1-android-0.12.0’ to build Android apk. And it suddenly built to fail and can stable reproducing the following error on only one of the docker machine.
Android PostProcess task “Creating Android manifest” took 180.8314 ms
DisplayProgressbar: Compiling resources
Android PostProcess task “Compiling resources” took 4.0098 ms
DisplayProgressbar: GenerateIl2cppPlatformProviders
Android PostProcess task “GenerateIl2cppPlatformProviders” took 1.1844 ms
DisplayProgressbar: IL2CPP
mmap(PROT_NONE) failed
Caught fatal signal - signo:6 code:-6 errno:0 addr:0x526
Obtained 20 stack frames. #0 0x007f573fb72980 in (Unknown) #1 0x007f573f7adfb7 in (Unknown) #2 0x007f573f7af921 in (Unknown) #3 0x007f55e4aa8dbd in (Unknown) #4 0x007f55e4aa8e2a in (Unknown) #5 0x007f55e4aabf90 in (Unknown) #6 0x007f55e4aac35d in (Unknown) #7 0x007f55e4aac47c in (Unknown) #8 0x007f55e4aad328 in (Unknown) #9 0x007f55e4ab017b in (Unknown) #10 0x007f55e4ab0355 in (Unknown) #11 0x007f55e4a83251 in (Unknown) #12 0x007f55e4a387b3 in (Unknown) #13 0x007f55e4a3881a in (Unknown) #14 0x000000401ba0af in (Unknown) #15 0x00000041217f68 in Mono.Cecil.ModuleDefinition:ReadModule (Mono.Disposable1<System.IO.Stream>,string,Mono.Cecil.ReaderParameters) #16 0x000000412f13ec in Mono.Cecil.BaseAssemblyResolver:GetAssembly (string,Mono.Cecil.ReaderParameters) #17 0x000000412f0b60 in Mono.Cecil.BaseAssemblyResolver:Resolve (Mono.Cecil.AssemblyNameReference,Mono.Cecil.ReaderParameters) #18 0x000000412f1f70 in UnityEditor.MonoAssemblyStripping/<>c__DisplayClass6_0:<ResolveAssemblyReferences>b__0 (Mono.Cecil.AssemblyNameReference) #19 0x000000412eff2c in UnityEditor.MonoAssemblyStripping:CollectAssembliesRecursive (System.Collections.Generic.IEnumerable1<Mono.Cecil.AssemblyDefinition>)
Aborted
Build Unity Android_Apk fail
Fail to run the plugin because of error(Process exited with an error: 1)
Spending a lot of time trying to compile unity-2020.3-mbe without the compile option “USE_MUNMAP”,but it never succeeded.(Endless compile errors and environment issues)
So, I had to keep searching and finally found that it seemed to be related to the virtual memory setting of linux.
The sysctl vm.overcommit_memory of the machine was set to 0, and could help if set to 1 (always overcommit) I guess.
As I had no privilege to change the setting of the previous machine,I ran another machine with it set to 1, and repeatly run the build task over 100 times.
The problem did not recur again,in an inelegant way.
Wow that was a very frustrating - and seemingly random issue. Unfortunately overcommit_memory did not fix this issue for us. It seems to be related to vm.max_map_count which is by default set too low at ~65k.
Fix:
What fixed it for us was setting it to sysctl -w vm.max_map_count=262144
Android PostProcess task "Compiling resources" took 3499.2199 ms
DisplayProgressbar: GenerateIl2cppPlatformProviders
Android PostProcess task "GenerateIl2cppPlatformProviders" took 1.3032 ms
DisplayProgressbar: IL2CPP
mmap(PROT_NONE) failed
Caught fatal signal - signo:6 code:-6 errno:0 addr:0x99
Obtained 19 stack frames.
#0 0x007f7194a02980 in (Unknown)
#1 0x007f719463dfb7 in (Unknown)
#2 0x007f719463f921 in (Unknown)
#3 0x007f70602b7e01 in (Unknown)
#4 0x007f70602b7e6e in (Unknown)
#5 0x007f70602bafd4 in (Unknown)
#6 0x007f70602bb23d in (Unknown)
#7 0x007f70602bc32e in (Unknown)
#8 0x007f70602bf1bf in (Unknown)
#9 0x007f70602bf399 in (Unknown)
#10 0x007f7060292293 in (Unknown)
#11 0x007f70602477ff in (Unknown)
#12 0x007f7060247866 in (Unknown)
#13 0x000000417ce21f in (Unknown)
#14 0x000000407f9338 in Mono.Cecil.ModuleDefinition:ReadModule (Mono.Disposable`1<System.IO.Stream>,string,Mono.Cecil.ReaderParameters)
#15 0x0000004088c0d8 in Mono.Cecil.BaseAssemblyResolver:GetAssembly (string,Mono.Cecil.ReaderParameters)
#16 0x00000040888830 in Mono.Cecil.BaseAssemblyResolver:Resolve (Mono.Cecil.AssemblyNameReference,Mono.Cecil.ReaderParameters)
#17 0x00000041f97ef0 in UnityEditor.MonoAssemblyStripping/<>c__DisplayClass6_0:<ResolveAssemblyReferences>b__0 (Mono.Cecil.AssemblyNameReference)
#18 0x00000041f962e4 in UnityEditor.MonoAssemblyStripping:CollectAssembliesRecursive (System.Collections.Generic.IEnumerable`1<Mono.Cecil.AssemblyDefinition>)
Aborted (core dumped)
Build failed, with exit code 134