[Jack-Devel] jack_port_get_buffer segfaults

PrevNext  Index
DateThu, 21 Apr 2011 16:42:00 +0300
From Dan Muresan <[hidden] at gmail dot com>
To[hidden] at jackaudio dot org
Follow-UpGabriel M. Beddingfield Re: [Jack-Devel] jack_port_get_buffer segfaults
I keep getting segfaults inside a process thread (non-callback model)
when calling jack_port_get_buffer. Is it possible that Jack zombifies
the client and frees the memory associated to the port "behind my
back"? I.e. can this happen without any on_shutdown or
port_registration notifications delivered to the application?

As a separate issue, I don't understand how the process thread can
time out. A while ago Paul mentioned that ardour uses semaphores and
that those are the closest thing to real-time IPC. I couldn't find any
semaphores at all in ardour, but I came up with this code:

  for (;;) {
    jack_nframes_t nframes = jack_cycle_wait (jclient);
    if (nframes <= 0 || zombified) break;
    sample_t *in = jack_port_get_buffer (jport, nframes);  // <
sporadic SEGFAULT

    size_t avail = jack_ringbuffer_write_space (jbuf) / sizeof (sample_t);
    if (avail < nframes) nframes = avail;
    jack_ringbuffer_write (jbuf, (const char *) in, nframes * sizeof
(sample_t));
    jack_cycle_signal (jclient, 0);

    if (nframes > 0) {
      struct sembuf sops1 = { .sem_num = 0, .sem_op = nframes, .sem_flg = 0 };
      semop (jbufavail_sem, &sops1, 1);
    }
  }

In theory this should be immune to anything the non-realtime threads
do, but in practice I get zombifications (and segfaults) often enough.
Any ideas on what I might be missing?
PrevNext  Index

1303393333.1712_0.ltw:2,a <BANLkTimQO+nLh+hMfyfQ2JpN-iaoZmnC9Q at mail dot gmail dot com>