On Monday, January 11, 2021 at 5:26:51 AM UTC-5 Nadav Har'El wrote:
> On Mon, Jan 11, 2021 at 11:43 AM Deepak Krishnan <[email protected]> > wrote: > >> >> >> On Monday, 11 January, 2021 at 1:47:22 pm UTC+5:30 Nadav Har'El wrote: >> >> Interesting. Theoretically, there is no reason why we didn't reach >>> preempt_enable() and enabled preemption. If we didn't, there is one >>> possible explanation: The thread's stack was allocated with mmap() without >>> pre-population (MAP_STACK or MAP_POPULATE), so when the thread began to >>> execute it had to page-fault its own stack, which failed. >>> >>> I'll try to prepare a test and a patch for this issue - if I can >>> reproduce it (the patch itself should be trivial). >>> >>> Stay tuned. >>> >> >> Thank you. I'll watch for your updates. >> > > I just sent a patch titled "[PATCH] pthread_create() - prefault top of > stack" - can you please test it with your application? > > The patch is just one line of code - with a lot of additional tests, > comments, etc. :-) > > Unfortunately, this is not a 100% foolproof solution, as explained in > https://github.com/cloudius-systems/osv/issues/143 - if a thread's stack > is not pre-allocated, we can always have random (but relatively rare) > crashes when internal OSv code which has preemption disabled needs to use > the stack and crosses over to a previously unused stack page that needs to > be paged in. This should be rare, but can happen. Waldek did submit a 100% > (?) solution once, but I don't remember what became of it :-( If you can > modify your application, a good workaround is when you use mmap() to > allocate thread stacks, use the MAP_STACK option. This option is a no-op on > Linux, but does the same as MAP_POPULATE on OSv so works around these bugs. > If you have some time to review it I can find this patch, if necessary adjust it to apply to the latest source version and re-send it to the list :-) > > >>> >>>> >>>> Thanks >>>> Deepak >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "OSv Development" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/osv-dev/4b814e35-7384-4123-ac42-7523e292b29bn%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/osv-dev/4b814e35-7384-4123-ac42-7523e292b29bn%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "OSv Development" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/osv-dev/dd8bc7c0-7606-4d70-bd36-893d4a934258n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/osv-dev/dd8bc7c0-7606-4d70-bd36-893d4a934258n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/1e1e62ac-90d4-40c7-bbb2-c773d9dfb06fn%40googlegroups.com.
