<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/21 Markus Pfeiffer <span dir="ltr"><<a href="mailto:markus.pfeiffer@morphism.de" target="_blank">markus.pfeiffer@morphism.de</a>></span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<div><div class="h5"><br>
On Sat, Apr 13, 2013 at 12:14:15AM +0400, vasily postnicov wrote:<br>
> I've started sourceforge project, where I put sbcl-1-1.6 patched for DragonFly.<br>
> I almost gave up fixing threads support, so it is switched off by now.<br>
><br>
> Here is pkgsrc package (based on original lang/sbcl):<br>
> <a href="http://shamazmazum.users.sourceforge.net/sbcl.tar" target="_blank">http://shamazmazum.users.sourceforge.net/sbcl.tar</a><br>
><br>
> Can anyone upload it to DragonFly's pkgsrc tree? I can maintain this package<br>
> and send new versions on regular basis.<br>
<br>
</div></div>Out of interest: What stops threads from working? Is it a DragonFly issue or<br>
is it just that SBCLs thread model is not easily ported?<br>
<span class=""><font color="#888888"><br>
Markus<br>
</font></span></blockquote></div><br></div><div class="gmail_extra">Playing with commenting lines out. The latest thing I found is this:<br><br></div><div class="gmail_extra">There is perform_thread_post_mortem function inside path_to_sbcl/src/runtime/thread.c<br>
<br>>static void*<br>>perform_thread_post_mortem(struct thread_post_mortem *post_mortem)<br>>{<br>>#ifdef CREATE_POST_MORTEM_THREAD<br>>    pthread_detach(pthread_self());<br>>#endif<br>>    if (post_mortem) {<br>
>        gc_assert(!pthread_join(post_mortem->os_thread, NULL));<br>>        gc_assert(!pthread_attr_destroy(post_mortem->os_attr));<br>>        free(post_mortem->os_attr);<br></div><div class="gmail_extra">
>        // NOTE NEXT LINE<br></div><div class="gmail_extra">>        os_invalidate(post_mortem->os_address, THREAD_STRUCT_SIZE);<br>>        free(post_mortem);<br>>    }<br>>    return NULL;<br>>}<br>
<br></div><div class="gmail_extra">If you remove call of os_invalidate, SBCL works without crashes. os_invalidate is opposing/freeing call after we os_validate thread->os_address. os_validate/os_invalidate are wrappers for mmap/munmap and can be found in path_to_sbcl/src/runtime/bsd-os.c<br>
<br></div><div class="gmail_extra">os_validate is called in create_thread_struct. There is a note on this:<br><br>>    /* May as well allocate all the spaces at once: it saves us from<br>>     * having to decide what to do if only some of the allocations<br>
>     * succeed. SPACES must be appropriately aligned, since the GC<br>>     * expects the control stack to start at a page boundary -- and<br>>     * the OS may have even more rigorous requirements. We can't rely<br>
>     * on the alignment passed from os_validate, since that might<br>>     * assume the current (e.g. 4k) pagesize, while we calculate with<br>>     * the biggest (e.g. 64k) pagesize allowed by the ABI. */<br>>     spaces=os_validate(0, THREAD_STRUCT_SIZE);<br>
>     if(!spaces)<br>>          return NULL;<br>>    /* Aligning up is safe as THREAD_STRUCT_SIZE has<br>>     * THREAD_ALIGNMENT_BYTES padding. */<br>>    aligned_spaces = (void *)((((uword_t)(char *)spaces)<br>
>                               + THREAD_ALIGNMENT_BYTES-1)<br>>                              &~(uword_t)(THREAD_ALIGNMENT_BYTES-1));<br><br></div><div class="gmail_extra">Still have no idea why sometimes it works and sometimes crashes.<br>
</div></div>