caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nathaniel Gray" <n8gray@gmail.com>
To: "Damien Doligez" <damien.doligez@inria.fr>
Cc: "Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Help interfacing with C
Date: Fri, 18 Aug 2006 13:09:10 -0700	[thread overview]
Message-ID: <aee06c9e0608181309r5b20469n755cf5d6ed04f26@mail.gmail.com> (raw)
In-Reply-To: <86D76069-A8CF-4EBD-B9D6-E988652E46F3@inria.fr>

On 8/18/06, Damien Doligez <damien.doligez@inria.fr> wrote:
> Hello,
>
> On 2006-08-16, at 21:34, Nathaniel Gray wrote:
>
> > I'm having a heck of a time figuring out why this code *doesn't* work:
>
> Unless you really know what you're doing, you should use the new macros
> (CAMLparam*, CAMLlocal*, CAMLreturn) instead of Begin_roots/End_roots.
> They are slightly less error-prone.

This is a patch to unix.c in the compiler so I'm following the idiom used there.

> > /* fdlist is a list of (file_descr * 'a) pairs.  Filter by FD_ISSET */
> > static value fdset_to_fdlist2(value fdlist, fd_set *fdset)
> > {
> >  value l, p, newres;
> >  value res = Val_int(0);
> >
> >  Begin_roots4(l, p, res, newres);  /* I know, this is aggressive */
> >    for (l = fdlist; l != Val_int(0); l = Field(l, 1)) {
> >      p = Field(l, 0);
> >      int fd = Int_val(Field(p, 0));
> >      if (FD_ISSET(fd, fdset)) {
> >        newres = alloc_small(2, 0);
> >        Field(newres, 0) = p;
> >        Field(newres, 1) = res;
> >        res = newres;
> >      }
> >    }
> >  End_roots();
> >  return res;
> > }
>
> Look at your Begin_roots4.  One of the four parameters is
> uninitialized when you first call alloc_small.  If the minor GC
> is triggered by this allocation, it can result in a segment
> violation or worse.

That's not the problem, but thanks for the tip.  The code crashes
after alloc_small, and quite reliably.

> PS. Maybe there are some other bugs in your code.

You're being too kind.  ;^)  There certainly is at least one other
bug, and I still don't know what it is.  Any other ideas?

Cheers,
-n8

-- 
>>>-- Nathaniel Gray -- Caltech Computer Science ------>
>>>-- Mojave Project -- http://mojave.cs.caltech.edu -->


  reply	other threads:[~2006-08-18 20:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-16 19:34 Nathaniel Gray
2006-08-17  3:49 ` [Caml-list] " malc
2006-08-18 21:00   ` Nathaniel Gray
2006-08-17  5:56 ` Bardur Arantsson
2006-08-18  7:10   ` [Caml-list] " Olivier Andrieu
2006-08-18 15:50     ` Bardur Arantsson
2006-08-18 21:33   ` [Caml-list] " Nathaniel Gray
2006-08-18 22:24     ` Bardur Arantsson
2006-08-19  0:33       ` [Caml-list] " Nathaniel Gray
2006-08-19  6:03         ` Bardur Arantsson
2006-08-21 22:45           ` [Caml-list] " Nathaniel Gray
2006-08-19  8:30         ` Olivier Andrieu
2006-08-21 22:35           ` Nathaniel Gray
2006-08-19  9:03     ` Richard Jones
2006-08-19  9:41       ` skaller
2006-08-18  8:46 ` [Caml-list] " Damien Doligez
2006-08-18 20:09   ` Nathaniel Gray [this message]
2006-08-23 23:36 ` Nathaniel Gray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aee06c9e0608181309r5b20469n755cf5d6ed04f26@mail.gmail.com \
    --to=n8gray@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=damien.doligez@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).