Giter VIP home page Giter VIP logo

Comments (6)

ArsenArsen avatar ArsenArsen commented on June 3, 2024

sysdeps or kernel, frankly, though we should probably provide some cross-thread communication utilities for this and other cases that need it

from mlibc.

64 avatar 64 commented on June 3, 2024

Handling this seems really extremely horrible. I don't think many programs use these functions in multithreaded environments, so maybe we could get away with some assertion that no threads are spawned and wait for a proper kernel fix.

from mlibc.

ArsenArsen avatar ArsenArsen commented on June 3, 2024

Handling this seems really extremely horrible. I don't think many programs use these functions in multithreaded environments, so maybe we could get away with some assertion that no threads are spawned and wait for a proper kernel fix.

there most likely won't be a proper kernel fix, afaik

I agree that we should do this in the Linux sysdeps until the necessity of a real fix is observed, and it should likely be:

  • a global credentials lock that prevents forking and cloning as well as other setxid ops,
  • enumerating threads via /proc/self/tasks or w/e it's called,
  • setting some atomic counter to the number of threads found,
  • deliver each SIG32 or something,
  • wait, with a futex+timeout or something, for all threads to change xid,
  • if any didn't (counter != 0), abort, else
  • iterate Tcbs to find the xid errnos,
  • if any but not all failed or if they failed differently, abort, else return errno
  • if none failed, return 0

(edit for elaboration: assert thread count == 0, for the time being, if it becomes necessary, implement the above, or try to bargain with the Linux devs)
it's horrible but it is what it is

from mlibc.

avdgrinten avatar avdgrinten commented on June 3, 2024

It's not necessary (or useful) to iterate over /proc/self/tasks since we can simply keep a global list of threads. But the remainder of the procedure sounds right.

from mlibc.

ArsenArsen avatar ArsenArsen commented on June 3, 2024

It's not necessary (or useful) to iterate over /proc/self/tasks since we can simply keep a global list of threads. But the remainder of the procedure sounds right.

the usefulness is that it covers the edge case of the program itself cloning without using pthread_create (I think the signal handler should be inherited well enough for this)

from mlibc.

avdgrinten avatar avdgrinten commented on June 3, 2024

If a program does syscall(SYS_CLONE), all hope to implement anything thread-related in a sane way is lost anyway. For example, such threads won't have a working TLS.

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.