Skip to content

[Android] Segmentation fault in libcoreclr.so #11661

Closed

Description

@yanzhenms

Hi, after followed this tutorial https://github.com/qmfrederik/coredroid, I got a lot of binaries successfull. I pushed them to Android /data/local/tmp/ and try to run a HelloWorld sample. It doesn't show "Hello, world" but gives me a "segmentation fault in libcoreclr.so".

HWNXT:/data/local/tmp/hello1 $ ../dotnet/corerun  hello
WARNING: linker: /data/local/tmp/dotnet/libcoreclr.so: unused DT entry: type 0xf arg 0xeba
Segmentation fault

Are there pre-built binaries or docker for Android cross built so I can save some time?

Thanks~

Activity

  1. janvorli commented on Dec 13, 2018

    @janvorli
    Member

    I am not aware of any prebuilt binaries availability. Have you tried to run it under lldb as the tutorial describes? That could give us some idea on what's wrong.

  2. yanzhenms commented on Dec 18, 2018

    @yanzhenms
    Author

    I cannot build the master branch cause it keeps reporting "cannot find version.cpp" error, even if 'skipgenerateversion' argument is present, so I switch to release/2.2.

    I can build v2.2 successfully, and run it under lldb, I got the following information:

    (lldb) run /data/local/tmp/coredroid/helloworld.dll
    Process 24591 launched: '/home/yanzhen/.lldb/module_cache/remote-android/.cache/AA3284A1-3274-0BBC-7BC2-628EB50E7CE1-4B6635AD/corerun' (aarch64)
    (lldb) WARNING: linker: /data/local/tmp/coredroid/libcoreclr.so: unused DT entry: type 0xf arg 0xee1
    Process 24591 stopped
    * thread dotnet/coreclr#1, name = 'corerun', stop reason = signal SIGSEGV: address access protected (fault address: 0x7fb6ec2bd0)
        frame #0: 0x0000007fb7f5ba10 linker64`__dl__ZN6soinfo8relocateI20plain_reloc_iteratorEEbRK14VersionTrackerOT_RK10LinkedListIS_19SoinfoListAllocatorESB_ + 1144
    linker64`__dl__ZN6soinfo8relocateI20plain_reloc_iteratorEEbRK14VersionTrackerOT_RK10LinkedListIS_19SoinfoListAllocatorESB_:
    ->  0x7fb7f5ba10 <+1144>: str    x8, [x19]
        0x7fb7f5ba14 <+1148>: ldp    x8, x28, [x23, #0x8]
        0x7fb7f5ba18 <+1152>: add    x21, x21, #0x1            ; =0x1 
        0x7fb7f5ba1c <+1156>: cmp    x28, x8
    bt
    * thread dotnet/coreclr#1, name = 'corerun', stop reason = signal SIGSEGV: address access protected (fault address: 0x7fb6ec2bd0)
      * frame #0: 0x0000007fb7f5ba10 linker64`__dl__ZN6soinfo8relocateI20plain_reloc_iteratorEEbRK14VersionTrackerOT_RK10LinkedListIS_19SoinfoListAllocatorESB_ + 1144
        frame dotnet/coreclr#1: 0x0000007fb7f5aa70 linker64`__dl__ZN6soinfo10link_imageERK10LinkedListIS_19SoinfoListAllocatorES4_PK17android_dlextinfo + 520
        frame dotnet/coreclr#2: 0x0000007fb7f5dfb4 linker64`__dl__ZL14find_librariesP19android_namespace_tP6soinfoPKPKcmPS2_PNSt3__16vectorIS2_NS8_9allocatorIS2_EEEEmiPK17android_dlextinfob + 3312
        frame dotnet/coreclr#3: 0x0000007fb7f575a8 linker64`__dl__Z9do_dlopenPKciPK17android_dlextinfoPv + 504
        frame dotnet/coreclr#4: 0x0000007fb7f5457c linker64`__dl_dlopen + 60
        frame dotnet/coreclr#5: corerun`ExecuteManagedAssembly(currentExeAbsolutePath=0x0000007fb782e018, clrFilesAbsolutePath=0x0000007fb782e098, managedAssemblyAbsolutePath=0x0000007fb782f018, managedAssemblyArgc=0, managedAssemblyArgv=0x0000000000000000) at coreruncommon.cpp:344
        frame dotnet/coreclr#6: corerun`corerun(argc=2, argv=0x0000007ffffffdc8) at corerun.cpp:149
        frame dotnet/coreclr#7: corerun`main(argc=2, argv=0x0000007ffffffdc8) at corerun.cpp:161
        frame dotnet/coreclr#8: 0x0000007fb7e16710 libc.so`__libc_init + 92
        frame dotnet/coreclr#9: 0x000000555555e374 corerun`do_arm64_start + 64
        frame dotnet/coreclr#10: 0x0000007fb7f53e7c linker64`__dl__start + 8
    
  3. janvorli commented on Dec 18, 2018

    @janvorli
    Member

    It looks like there is a relocation in the libcoreclr.so and that is not allowed on Android. We used to have such an issue in the past, but at that time, the dynamic loader was not crashing with SIGSEGV, but rather showing "dlopen failed to open the libcoreclr.so with error dlopen failed: text relocations (DT_TEXTREL) found in 64-bit ELF file "/data/data/com.termux/files/usr/bin/Product/Linux.arm64.Debug/libcoreclr.so".
    Since we use -fPIC option when building coreclr, my guess is that some newly added / modified assembler helper is responsible for that.

  4. janvorli commented on Dec 21, 2018

    @janvorli
    Member

    @yanzhenms I am going to try it on my local Android device. I was actually able to build it from the master branch, the thing was to actually not to pass in the skipgenerateversion. This option seems to be broken for crossgen build now.
    But I needed to update the cross/build-android-rootfs.sh due to the fact that libicu and liblzma package versions were updated.

  5. transferred this issue fromdotnet/coreclron Jan 31, 2020
  6. added this to the Future milestone on Jan 31, 2020
  7. ghost added
    backlog-cleanup-candidateAn inactive issue that has been marked for automated closure.
    on Aug 2, 2023
  8. ghost closed this as completedon Aug 16, 2023
  9. ghost locked as resolved and limited conversation to collaborators on Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions