runtime icon indicating copy to clipboard operation
runtime copied to clipboard

dotnet ***.dll - Segmentation fault on Ubuntu ARM 32

Open livarcocc opened this issue 9 years ago • 8 comments

From @mubavoice on August 1, 2017 15:40

Steps to reproduce

  1. Install .net Core SDK 2.1.0-preview1-006958
  2. add signalR into the project
  3. compile the project and deploy to Linux Ubuntu mate running Ubuntu 16.04 in ODroid-xu4 (arm32) ( runtime already installed in Ubuntu with the same version of the runtime).
  4. run the dotnet web site with dotnet dlll-name.dll

Expected behavior

  1. The application is working fine in windows 10 environment.
  2. The same code compiled and published with "dotnet publish --runtime ubuntu.16.04-arm" should work

Actual behavior

  1. When we run the dotnet dll-name.dll, it fails in randomly and web site does not load.

Application some it throws Segmentation fault as soon as we run the 'dotnet Dahlia.dll' command. Some times it executes little futher and throws the segmentation fault. Below are the two scenarion it got failed.

1st Log:

droid@odroid:/dotnetprojects/Dahlia$ dotnet Dahlia.dll
: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using '/home/odroid/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
dbug: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[37]
      Reading data from file '/home/odroid/.aspnet/DataProtection-Keys/key-f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a.xml'.
dbug: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[37]
      Reading data from file '/home/odroid/.aspnet/DataProtection-Keys/key-2f1f3097-f7ac-419b-abf5-6a5dfd280585.xml'.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[18]
      Found key {f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a}.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[18]
      Found key {2f1f3097-f7ac-419b-abf5-6a5dfd280585}.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.DefaultKeyResolver[13]
      Considering key {f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a} with expiration date 2017-10-29 11:18:15Z as default key.
dbug: Microsoft.AspNetCore.DataProtection.TypeForwardingActivator[0]
      Forwarded activator type request from Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 to Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Culture=neutral, PublicKeyToken=adb9793829ddae60
dbug: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ManagedAuthenticatedEncryptorFactory[11]
      Using managed symmetric algorithm 'System.Security.Cryptography.Aes'.
dbug: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ManagedAuthenticatedEncryptorFactory[10]
      Using managed keyed hash algorithm 'System.Security.Cryptography.HMACSHA256'.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[2]
      Using key {f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a} as the default key.
dbug: Microsoft.AspNetCore.DataProtection.Internal.DataProtectionStartupFilter[0]
      Key ring with default key {f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a} was loaded during application startup.
dbug: Microsoft.AspNetCore.SignalR.HubEndPoint[0]
      Hub method 'updateDeviceState' is bound
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[3]
      Hosting starting
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[4]
      Hosting started
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[0]
      Loaded hosting startup assembly Dahlia
Hosting environment: Production
Content root path: /dotnetprojects/Dahlia
Now listening on: http://[::]:5000
Application started. Press Ctrl+C to shut down.
dbug: Microsoft.AspNetCore.Server.Kestrel[1]
      Connection id "0HL6OUDOR8B5V" started.
dbug: Microsoft.AspNetCore.Server.Kestrel[1]
      Connection id "0HL6OUDOR8B60" started.
Segmentation fault
odroid@odroid:/dotnetprojects/Dahlia$

2nd Log

dotnet Dahlia.dll
: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using '/home/odroid/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
dbug: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[37]
      Reading data from file '/home/odroid/.aspnet/DataProtection-Keys/key-f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a.xml'.
dbug: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[37]
      Reading data from file '/home/odroid/.aspnet/DataProtection-Keys/key-2f1f3097-f7ac-419b-abf5-6a5dfd280585.xml'.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[18]
      Found key {f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a}.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[18]
      Found key {2f1f3097-f7ac-419b-abf5-6a5dfd280585}.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.DefaultKeyResolver[13]
      Considering key {f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a} with expiration date 2017-10-29 11:18:15Z as default key.
dbug: Microsoft.AspNetCore.DataProtection.TypeForwardingActivator[0]
      Forwarded activator type request from Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 to Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Culture=neutral, PublicKeyToken=adb9793829ddae60
dbug: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ManagedAuthenticatedEncryptorFactory[11]
      Using managed symmetric algorithm 'System.Security.Cryptography.Aes'.
dbug: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ManagedAuthenticatedEncryptorFactory[10]
      Using managed keyed hash algorithm 'System.Security.Cryptography.HMACSHA256'.
dbug: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[2]
      Using key {f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a} as the default key.
dbug: Microsoft.AspNetCore.DataProtection.Internal.DataProtectionStartupFilter[0]
      Key ring with default key {f0fe4c62-5cef-46fa-83c5-5bb2d7cd7d4a} was loaded during application startup.
dbug: Microsoft.AspNetCore.SignalR.HubEndPoint[0]
      Hub method 'updateDeviceState' is bound
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[3]
      Hosting starting
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[4]
      Hosting started
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[0]
      Loaded hosting startup assembly Dahlia
Hosting environment: Production
Content root path: /dotnetprojects/Dahlia
Now listening on: http://[::]:5000
Application started. Press Ctrl+C to shut down.
dbug: Microsoft.AspNetCore.Server.Kestrel[1]
      Connection id "0HL6OUF6DCMQB" started.
dbug: Microsoft.AspNetCore.Server.Kestrel[1]
      Connection id "0HL6OUF6DCMQA" started.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/
dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[4]
      The request path / does not match a supported file type
dbug: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[9]
      AuthenticationScheme: Bearer was not authenticated.
dbug: Microsoft.AspNetCore.Builder.RouterMiddleware[1]
      Request did not match any routes.
dbug: Microsoft.AspNetCore.Routing.RouteBase[1]
      Request successfully matched the route with name 'default' and template '{controller=Home}/{action=Index}/{id?}'.
dbug: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action Dahlia.Controllers.HomeController.Index (Dahlia)
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action method Dahlia.Controllers.HomeController.Index (Dahlia) with arguments ((null)) - ModelState is Valid
dbug: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action method Dahlia.Controllers.HomeController.Index (Dahlia), returned result Microsoft.AspNetCore.Mvc.ViewResult.
dbug: Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine[1]
      View lookup cache miss for view 'Index' in controller 'Home'.
Segmentation fault

Environment data

dotnet --info output:

Microsoft .NET Core Shared Framework Host

Version : 2.1.0-dev-di-25531-02 Build : 7a391b9234369c48fe8d809d549e349259be00e5

Copied from original issue: dotnet/cli#7326


Edited for formatting only by @Eilon

livarcocc avatar Aug 01 '17 17:08 livarcocc

@Eilon as FYI, both of these appear to be in the web stack.

Petermarcu avatar Aug 01 '17 17:08 Petermarcu

Is it possible to get a stack trace for a seg fault? Without that it's impossible to say what's happening here.

Eilon avatar Aug 03 '17 00:08 Eilon

If you're running from a bash shell, you should be able to run ulimit -c unlimited prior to executing the dotnet process. This tells bash to capture and save a core dump of the crashing process no matter the size. On my debian VM, this creates a file named "core" in the PWD, but this might depend on how your distro is configured.

You can then install lldb-3.6 and use that to debug the core dump. You can use normal lldb commands like bt to get native stack traces. You can also load libsosplugin.so for managed debugging which gives you commands like sos ClrStack.

More details on how to do these things can be found at https://github.com/dotnet/coreclr/blob/master/Documentation/building/debugging-instructions.md and http://blogs.microsoft.co.il/sasha/2017/02/26/analyzing-a-net-core-core-dump-on-linux/.

There's a lot of duplication between those two links, but the second link has a nice tip on how to correlate an sos thread "OSID" to an lldb thread number using gdb's info threads command.

I have a raspberry pi, so I might bring it in tomorrow and take a crack at reproing this issue.

The following is part of a debugging session of a dump from an idle asp.net core app that I kill -ABRT'd to give you all a sense of what debugging with lldb and libsosplugin.so looks like.

(lldb) plugin load /home/shalter/.dotnet/shared/Microsoft.NETCore.App/1.1.0/libsosplugin.so
(lldb) setclrpath /home/shalter/.dotnet/shared/Microsoft.NETCore.App/1.1.0
Set load path for sos/dac/dbi to '/home/shalter/.dotnet/shared/Microsoft.NETCore.App/1.1.0/'
(lldb) thread list
Process 0 stopped
* thread dotnet/core-setup#1: tid = 0, 0x00007efc4a8b604f libpthread.so.0`__pthread_cond_wait + 191, name = 'dotnet', stop reason = signal SIGABRT
  thread dotnet/core-setup#2: tid = 1, 0x00007efc49dbcaed libc.so.6`__poll + 45, stop reason = signal SIGABRT
  thread dotnet/core-setup#3: tid = 2, 0x00007efc4a8b91ad libpthread.so.0, stop reason = signal SIGABRT
  thread dotnet/core-setup#4: tid = 3, 0x00007efc4a8b604f libpthread.so.0`__pthread_cond_wait + 191, stop reason = signal SIGABRT
  thread dotnet/core-setup#5: tid = 4, 0x00007efc4a8b604f libpthread.so.0`__pthread_cond_wait + 191, stop reason = signal SIGABRT
  thread dotnet/core-setup#6: tid = 5, 0x00007efc4a8b63f8 libpthread.so.0`__pthread_cond_timedwait + 296, stop reason = signal SIGABRT
  thread dotnet/core-setup#7: tid = 6, 0x00007efc4a8b8a9d libpthread.so.0, stop reason = signal SIGABRT
  thread dotnet/core-setup#8: tid = 7, 0x00007efc49dc15b9 libc.so.6`syscall + 25, stop reason = signal SIGABRT
(lldb) sos Threads
ThreadCount:      4
UnstartedThread:  0
BackgroundThread: 2
PendingThread:    0
DeadThread:       1
Hosted Runtime:   no
                                                                                                        Lock
       ID OSID ThreadOBJ           State GC Mode     GC Alloc Context                  Domain           Count Apt Exception
XXXX    1 595a 0000000002607860  2020020 Preemptive  0x7efab8077670:0x7efab8078060     000000000260A100 0     Ukn
XXXX    2 5960 0000000002610B40    21220 Preemptive  (nil):(nil)                       000000000260A100 0     Ukn (Finalizer)
XXXX    3 5962 000000000278AAB0    21220 Preemptive  0x7efab8083e10:0x7efab8083fd0     000000000260A100 0     Ukn
   1    4    0 0000000002790410  1031820 Preemptive  (nil):(nil)                       000000000260A100 0     Ukn (Threadpool Worker)
(lldb) setsostid 5962 8
Mapped sos OS tid 0x5962 to lldb thread index 8
(lldb) sos ClrStack
OS Thread Id: 0x5962 (8)
        Child SP               IP Call Site
00007EFC417E77F8 00007efc49dc15b9 [InlinedCallFrame: 00007efc417e77f8] Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv+NativeMethods.uv_run(Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvLoopHandle, Int32)
00007EFC417E77F8 00007efbcfd994ea [InlinedCallFrame: 00007efc417e77f8] Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv+NativeMethods.uv_run(Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvLoopHandle, Int32)
00007EFC417E77E0 00007EFBCFD994EA DomainBoundILStubClass.(Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvLoopHandle, Int32)
00007EFC417E7890 00007EFBCFD99418 Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.run(Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvLoopHandle, Int32)
00007EFC417E78B0 00007EFBCFD97B8D Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelThread.ThreadStart(System.Object)
00007EFC417E7910 00007EFBCF899E71 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
00007EFC417E7B50 00007efc490cb9c7 [GCFrame: 00007efc417e7b50]
00007EFC417E7D30 00007efc490cb9c7 [DebuggerU2MCatchHandlerFrame: 00007efc417e7d30]
(lldb) bt
* thread dotnet/core-setup#1: tid = 0, 0x00007efc4a8b604f libpthread.so.0`__pthread_cond_wait + 191, name = 'dotnet', stop reason = signal SIGABRT
  * frame #0: 0x00007efc4a8b604f libpthread.so.0`__pthread_cond_wait + 191
    frame dotnet/core-setup#1: 0x00007efc49358452 libcoreclr.so`CorUnix::CPalSynchronizationManager::ThreadNativeWait(CorUnix::_ThreadNativeWaitData*, unsigned int, CorUnix::ThreadWakeupReason*, unsigned int*) + 322
    frame dotnet/core-setup#2: 0x00007efc49358110 libcoreclr.so`CorUnix::CPalSynchronizationManager::BlockThread(CorUnix::CPalThread*, unsigned int, bool, bool, CorUnix::ThreadWakeupReason*, unsigned int*) + 528
    frame dotnet/core-setup#3: 0x00007efc4935cfc1 libcoreclr.so`CorUnix::InternalWaitForMultipleObjectsEx(CorUnix::CPalThread*, unsigned int, void* const*, int, unsigned int, int) + 1873
    frame dotnet/core-setup#4: 0x00007efc48fa96e8 libcoreclr.so`Thread::DoAppropriateWaitWorker(int, void**, int, unsigned int, WaitMode) + 968
    frame dotnet/core-setup#5: 0x00007efc48fa42f0 libcoreclr.so`Thread::DoAppropriateWait(int, void**, int, unsigned int, WaitMode, PendingSync*) + 80
    frame dotnet/core-setup#6: 0x00007efc48ff98c0 libcoreclr.so`WaitHandleNative::CorWaitOneNative(SafeHandle*, int, bool, bool) + 320
    frame dotnet/core-setup#7: 0x00007efbcf89a98d
    frame dotnet/core-setup#8: 0x00007efbcf89a85f
    frame dotnet/core-setup#9: 0x00007efbcfd8c70e
    frame dotnet/core-setup#10: 0x00007efbcfd87b19
    frame dotnet/core-setup#11: 0x00007efbcfd68867
    frame dotnet/core-setup#12: 0x00007efc490cb9c7 libcoreclr.so`CallDescrWorkerInternal + 124
    frame dotnet/core-setup#13: 0x00007efc48fdf46c libcoreclr.so`MethodDescCallSite::CallTargetWorker(unsigned long const*, unsigned long*, int) + 876
    frame dotnet/core-setup#14: 0x00007efc490eda6a libcoreclr.so`RunMain(MethodDesc*, short, int*, PtrArray**) + 938
    frame dotnet/core-setup#15: 0x00007efc490edc73 libcoreclr.so`Assembly::ExecuteMainMethod(PtrArray**, int) + 227
    frame dotnet/core-setup#16: 0x00007efc48f23358 libcoreclr.so`CorHost2::ExecuteAssembly(unsigned int, char16_t const*, int, char16_t const**, unsigned int*) + 472
    frame dotnet/core-setup#17: 0x00007efc48efef63 libcoreclr.so`coreclr_execute_assembly + 259
    frame dotnet/runtime#2412: 0x00007efc497f4363 libhostpolicy.so`coreclr::execute_assembly(void*, unsigned int, int, char const**, char const*, unsigned int*) + 131
    frame dotnet/core-setup#19: 0x00007efc497e85d5 libhostpolicy.so`run(arguments_t const&) + 5317
    frame dotnet/runtime#2413: 0x00007efc497e8c32 libhostpolicy.so`corehost_main + 594
    frame dotnet/core-setup#21: 0x00007efc49aafd3f libhostfxr.so`execute_app(std::string const&, corehost_init_t*, int, char const**) + 207
    frame dotnet/core-setup#22: 0x00007efc49ab6881 libhostfxr.so`fx_muxer_t::read_config_and_execute(std::string const&, std::string const&, std::unordered_map<std::string, std::vector<std::string, std::allocator<std::string> >, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, std::vector<std::string, std::allocator<std::string> > > > > const&, int, char const**, host_mode_t) + 2833
    frame dotnet/runtime#2414: 0x00007efc49ab5ca6 libhostfxr.so`fx_muxer_t::parse_args_and_execute(std::string const&, std::string const&, int, int, char const**, bool, host_mode_t, bool*) + 3014
    frame dotnet/core-setup#24: 0x00007efc49ab6e0c libhostfxr.so`fx_muxer_t::execute(int, char const**) + 956
    frame dotnet/runtime#2415: 0x00007efc49aafdb5 libhostfxr.so`hostfxr_main + 53
    frame dotnet/runtime#2416: 0x000000000040cd52 dotnet`run(int, char const**) + 546
    frame dotnet/runtime#2417: 0x000000000040ce90 dotnet`main + 160
    frame dotnet/core-setup#28: 0x00007efc49cfeb45 libc.so.6`__libc_start_main + 245
    frame dotnet/core-setup#29: 0x000000000040ad74 dotnet`_start + 41

halter73 avatar Aug 03 '17 02:08 halter73

I will try to get the dump and get back to you. This happens only on Ubuntu mate xu4 and not on raspberry pi3. In raspberry pi 3 its working fine.

mubavoice avatar Aug 04 '17 17:08 mubavoice

@mubavoice any update?

steveharter avatar Nov 16 '17 17:11 steveharter

Sorry Guys, I could not find time to check again. This week i will try to spend time to check this issue again and provide the details.

Thanks, Mubarak M

On Thu, Nov 16, 2017 at 10:45 PM, Steve Harter [email protected] wrote:

@mubavoice https://github.com/mubavoice any update?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dotnet/core-setup/issues/2954#issuecomment-344993362, or mute the thread https://github.com/notifications/unsubscribe-auth/AGmG9UKPATL8bELZPYckhaYo0PdwVE4lks5s3G2dgaJpZM4OqBQy .

mubavoice avatar Nov 17 '17 04:11 mubavoice

Closing this as no update \ repro \ call stack. Please reopen if additional information, or create a new issue in the coreclr repo since it appear to be a runtime issue. Thanks

steveharter avatar Feb 22 '18 15:02 steveharter

Hello, my app raised the same issue. I was using the .net core 2.1 and hosting the app at ubuntu 16.04. My app reading the text from a file and doing a rsa encription, then it crashed with Segmentation fault. I debuged with strace which shows almost same as @florrain described. After some researching, I found it was cased by the ASCII filetype, so I delete the text file and re-create avoiding ASCII, it works finally!

So checking if there's any file created at windows. May it helps you.

FYI: 13 hours debugging a segmentation fault in .NET Core on Raspberry Pi and the solution was...

NeilQ avatar Jan 26 '19 09:01 NeilQ