Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Wait a sec .. I just realized you're copying the entire stack. If I understand correctly, that means that when you move stuff to a compute_lthread, the addresses of local variables change, don't they?

I often take addresses of local variables -- if I understood correctly, this deserves a huge warning in the documentation.



Correct. The local variables address change, but you can still access them, and pass them to functions. What you cannot do is save a pointer of a variable and access inside begin()/end().

I thought I added a warning in the lthread_compute_begin() section but apparently not. I'll go ahead and add it.


It might also be possible to have a "debug mode" that scans the stack while copying it to the lthread_compute_begin() thread, and warns you if any of it looks like pointers that point into the copied stack. It will probably be negligible compared to a long-running thread (compare 60 pointers against a lower and upper bound), and it might have false positives occasionally -- but could save a lot of debugging time...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: