Porting sbcl to DragonFly
vasily postnicov
shamaz.mazum at gmail.com
Wed Apr 24 10:26:13 PDT 2013
2013/4/21 Markus Pfeiffer <markus.pfeiffer at morphism.de>
> Hi,
>
> On Sat, Apr 13, 2013 at 12:14:15AM +0400, vasily postnicov wrote:
> > I've started sourceforge project, where I put sbcl-1-1.6 patched for
> DragonFly.
> > I almost gave up fixing threads support, so it is switched off by now.
> >
> > Here is pkgsrc package (based on original lang/sbcl):
> > http://shamazmazum.users.sourceforge.net/sbcl.tar
> >
> > Can anyone upload it to DragonFly's pkgsrc tree? I can maintain this
> package
> > and send new versions on regular basis.
>
> Out of interest: What stops threads from working? Is it a DragonFly issue
> or
> is it just that SBCLs thread model is not easily ported?
>
> Markus
>
Playing with commenting lines out. The latest thing I found is this:
There is perform_thread_post_mortem function inside
path_to_sbcl/src/runtime/thread.c
>static void*
>perform_thread_post_mortem(struct thread_post_mortem *post_mortem)
>{
>#ifdef CREATE_POST_MORTEM_THREAD
> pthread_detach(pthread_self());
>#endif
> if (post_mortem) {
> gc_assert(!pthread_join(post_mortem->os_thread, NULL));
> gc_assert(!pthread_attr_destroy(post_mortem->os_attr));
> free(post_mortem->os_attr);
> // NOTE NEXT LINE
> os_invalidate(post_mortem->os_address, THREAD_STRUCT_SIZE);
> free(post_mortem);
> }
> return NULL;
>}
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
os_validate is called in create_thread_struct. There is a note on this:
> /* May as well allocate all the spaces at once: it saves us from
> * having to decide what to do if only some of the allocations
> * succeed. SPACES must be appropriately aligned, since the GC
> * expects the control stack to start at a page boundary -- and
> * the OS may have even more rigorous requirements. We can't rely
> * on the alignment passed from os_validate, since that might
> * assume the current (e.g. 4k) pagesize, while we calculate with
> * the biggest (e.g. 64k) pagesize allowed by the ABI. */
> spaces=os_validate(0, THREAD_STRUCT_SIZE);
> if(!spaces)
> return NULL;
> /* Aligning up is safe as THREAD_STRUCT_SIZE has
> * THREAD_ALIGNMENT_BYTES padding. */
> aligned_spaces = (void *)((((uword_t)(char *)spaces)
> + THREAD_ALIGNMENT_BYTES-1)
> &~(uword_t)(THREAD_ALIGNMENT_BYTES-1));
Still have no idea why sometimes it works and sometimes crashes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dragonflybsd.org/pipermail/users/attachments/20130424/9f34792c/attachment-0002.html>
More information about the Users
mailing list