Comments (8)
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.
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.
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.
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.
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.
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.
Almost there. See comments in the patch.
thanks
from rumprun.
Comments addressed and everything works as expected. Merged.
from rumprun.
Related Issues (20)
- build.rs fails to detect xen headers HOT 3
- ./build-rr.sh hw gives error HOT 2
- Please add the documentation on what prevents the clang compiler
- NTP support
- Issue with ARM HOT 1
- build-rr.sh fails to detects Xen headers HOT 11
- Compile error for CC=cc ./build-rr.sh hw HOT 3
- Problem building on ARM HOT 2
- problem with networking on Xen HOT 1
- Zlib not found on Fedora 28 HOT 1
- Building for the RaspberryPi? HOT 11
- linking errors in rumprun-bake when building against newer netbsd sources HOT 1
- How to see the console ? HOT 1
- sendto not working as expected HOT 1
- Compilation error HOT 3
- Unable to run the example kernel in qemu on FreeBSD HOT 2
- Is Rumprum not maintained anymore? HOT 1
- Rumprun Redis (Debian 10 build) crashes with general protection error HOT 1
- run on hypervisor, rumprun how to implement pthreads?
- .build-rr.sh hw nbmake error: multiple definition of `debug_file' HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rumprun.