Git Product home page Git Product logo

Comments (4)

64 avatar 64 commented on June 9, 2024

This was also reproduced on #684 (specifically, RISC-V failing).

from mlibc.

qookei avatar qookei commented on June 9, 2024

As discussed on discord, the suspected cause is the following sequence of events:

  1. Thread 2 goes to sleep for a second.
  2. Thread 1 cancels thread 2, by first setting tcbCancelTriggerBit in tcb->cancelBits, then, if cancellation is enabled, sending a SIGCANCEL to the thread.
  3. Thread 2 wakes up after tcbCancelTriggerBit was set, but before the signal was sent.
  4. Thread 2 calls sleep again, sees that cancellation was requested, and exits via __mlibc_do_cancel.
  5. Thread 1 finally gets around to sending SIGCANCEL, but it's too late, as thread 2 has quit due to the cancellation request.
  6. Thread 1's call to sys_tgkill fails, and pthread_cancel erroneously forwards the error code.

The solution would be to check for tcb->cancelBits & tcbExitingBit if sys_tgkill fails, and if it's set, ignoring the error.

from mlibc.

ArsenArsen avatar ArsenArsen commented on June 9, 2024

to reproduce, run yes | parallel strace -e trace=tgkill -e status=failed qemu-riscv64 tests/posix-pthread_cancel on a ubuntu 20.04 machine. you'll need to watch out since the output will be spammed by useless exit codes since ubuntu 20.04 is too old for straces quiet option, but we've gotta match ci

Tange, O. (2022, May 22). GNU Parallel 20220522 ('NATO').
Zenodo. https://doi.org/10.5281/zenodo.6570228

from mlibc.

qookei avatar qookei commented on June 9, 2024

Also reproducible on AArch64: https://github.com/managarm/mlibc/runs/7482261270

from mlibc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.