Giter VIP home page Giter VIP logo

Comments (8)

DerangedMonkeyNinja avatar DerangedMonkeyNinja commented on August 27, 2024

I think this is due to the main thread getting run as PID 3, but any threads spawned by the main thread end using the default LWP context, and thus think they are PID 1.

At least, I was able to work around a similar issue by calling rump_pub_lwproc_newlwp(1) in main before doing anything with descriptors. I wasn't sure if this was really a bug or not though, due to the rump man page saying that "the association between host threads and the rump kernel curlwp is left to the caller"...

from rumprun.

anttikantee avatar anttikantee commented on August 27, 2024

It's a bug in _lwp.c, makelwp() should create threads in the same rump kernel process as the caller.

Instead of you calling rump_pub_lwproc_newlwp(1) in main() we should be calling rump_pub_lwproc_newlwp(getpid()) and switching to that lwp in the newly created bmk_thread.

The main reason why rumprun() calls newproc is so that you can have processes running with UID != 0. Also, later, the intention is supporting multiple calls to rumprun() in the same rumprun instance, i.e. "multiprocess" support.

from rumprun.

mato avatar mato commented on August 27, 2024

I've pushed a work in progress patch with some debugging printfs to the wip-lwp branch at 026bbb6.

However: it is not behaving as expected. I call rump_pub_lwproc_switch(next->rl_klwp) in schedhook, but rump_pub_lwproc_curlwp() inside the newly created thread is still returning 0x0.

Could there be some interaction going on with curlwp using __thread?

Example output from pthread_test with the patch:

mounted tmpfs on /tmp
makelwp: called in implicit context, not creating klwp
makelwp: called in implicit context, not creating klwp

=== calling "rumprun-xen" main() ===

testing pthread_join
makelwp: curlwp 0x596800 me->rl_klwp 0x596800
makelwp: new curlwp is 0x95f800
thread 0x0, curlwp 0x0
lwp_exit: me->rl_klwp 0x95f800 curlwp 0x0
success
makelwp: curlwp 0x95f800 me->rl_klwp 0x596800
makelwp: new curlwp is 0xa59800
panic: lwp 0x596800 (2:0) already running
rump kernel halting...
halted
PANIC: rumpuser panic
minios: halting, reason=0

from rumprun.

mato avatar mato commented on August 27, 2024

N.B. The releaselwp() call in _lwp_exit() is commented out deliberately since it would cause an assertion failure due to being called with curlwp=0x0.

from rumprun.

mato avatar mato commented on August 27, 2024

Ok, so sched_switch() calls schedhook and then sets the TLS to the thread we are switching to. This does not help if schedhook needs to call rump_pub_lwproc_switch().

I've change the order of the calls and added a few more fixes to call rump_pub_lwproc_releaselwp() from lwp_exit(). pthread_test now passes, including the file descriptor test.

from rumprun.

mato avatar mato commented on August 27, 2024

Force-pushed a new version, using a trampoline to set curlwp. Many thanks to @anttikantee for the jedi tips in figuring out how to implement this properly.

@anttikantee If you're happy with the patch as is at 9e5f4e5 then I think we can merge it. pthread_test passes and mysqld works :)

from rumprun.

anttikantee avatar anttikantee commented on August 27, 2024

Almost there. See comments in the patch.

thanks

from rumprun.

mato avatar mato commented on August 27, 2024

Comments addressed and everything works as expected. Merged.

from rumprun.

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.