Skip to content

ucontext_t fpregs ABI incompatibility #2555

Closed

Description

  • Your Windows build number: (Type ver at a Windows Command Prompt)

Microsoft Windows [Version 10.0.15063]

  • What you're doing and what's happening: (Copy&paste specific commands and their output, or include screen shots)

Given a ucontext_t *ctx pointer, I'm trying to access ctx->uc_mcontext.fpregs->_xmm[0].

  • What's wrong / what should be happening instead:

The ctx->uc_mcontext.fpregs field contains a NULL pointer. On a normal Linux system, the ctx->uc_mcontext.fpregs field is always a non-NULL pointer, presumably pointing to ctx->__fpregs_mem. Indeed, if I dig into ctx->__fpregs_mem, all the data is there as expected. So it seems WSL is simply not setting the ctx->uc_mcontext.fpregs field as it should.

Activity

  1. benhillis commented on Oct 10, 2017

    @benhillis
    Member

    Alex Rønne Petersen (@alexrp) - Thanks for posting, could you share an strace so I can narrow down what's happening?

  2. therealkenc commented on Oct 11, 2017

    @therealkenc

    Ben Hillis (@benhillis) - I don't know if a strace will show much, because there won't be a syscall fail.

    Richard's tight repro from unrelated #1692 (message) demonstrates the problem. Besides his gregs ask, fpregs are all nada. On Real Linux it's populated, natch.

    [...blah blah gdb startup]
    (gdb) break 16
    Breakpoint 1 at 0x40071d: file ucontext.c, line 16.
    (gdb) run
    Starting program: /home/ken/Devel/ucontext/ucontext
    
    Program received signal SIGSEGV, Segmentation fault.
    0x0000000000400812 in main () at ucontext.c:41
    41              *x = 3;
    (gdb) cont
    Continuing.
    
    Breakpoint 1, segv (sig=11, info=0x7ffffffddd40, context=0x7ffffffdd730) at ucontext.c:16
    16              printf("SIGSEGV at 0x%lx, fixing up\n", (unsigned long)fault_addr);
    (gdb) list
    11              ucontext_t *c = context;
    12              mcontext_t m = c->uc_mcontext;
    13              void *fault_addr = (void *)m.gregs[REG_CR2];
    14              void *addr;
    15
    16              printf("SIGSEGV at 0x%lx, fixing up\n", (unsigned long)fault_addr);
    17
    18              addr = mmap(fault_addr, 4096, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0, 0);
    19              if (addr == MAP_FAILED) {
    20                      printf("map failed!\n");
    (gdb) print m
    $1 = {gregs = {0, 255, 8, 8, 4195776, 140737488215856, 0, 0, 11, 140737488215104, 140737488215632, 0, 0, 3735928559,
        8, 140737488215616, 4196370, 66118, 356485103667, 0, 0, 0, 0}, fpregs = 0x0, __reserved1 = {0, 0, 0, 0, 0, 0, 0,
        0}}
    (gdb)
    
  3. alexrp commented on Oct 13, 2017

    @alexrp
    Author

    To be clear, the ucontext_t is obtained as the third argument from a signal handler that was installed via sigaction with SA_SIGINFO.

  4. therealkenc commented on Oct 13, 2017

    @therealkenc

    To be clear, the ucontext_t is obtained as the third argument from a signal handler that was installed via sigaction with SA_SIGINFO.

    Yep. In the test case I cited it is:

    static void segv(int sig, siginfo_t *info, void *context)
    {
    	ucontext_t *c = context;
    	mcontext_t m = c->uc_mcontext;
    [...]
    

    They were trapping SIGSEGV, but any signal will do. I assume you are trapping SIGFPE. I hope gregs is addressed also because that is valuable on its own merits, as is fpregs. I haven't tested it personally, but I am pretty sure libsigsegv is broken on WSL.

  5. shizhx commented on Dec 31, 2024

    @shizhx

    This issue remains unresolved. In many corporate environments, Windows runs on virtual machines, but often does not support nested virtualization. As a result, WSL2 and other virtual machines cannot be run, leaving only WSL1. Therefore, a natural idea is to run User Mode Linux to obtain a complete Linux kernel.

    Strongly hope to solve the problems of running UML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions