Bug#601657: libffado2 thread crashes with assertion failure

2010-10-28 Thread Max Kellermann
Package: libffado2   
Version: 2.0.1+svn1856-5
   
Severity: serious

The attached test program can trigger a (timing?) bug in libffado2,
which causes an assertion failure (i.e. crash of the whole
application).
#include 
#include 
#include 
#include 
#include 

enum {
MAX_STREAMS = 16,
PERIOD_SIZE = 1024,
NB_BUFFERS = 3,
};

static float buffer[PERIOD_SIZE];

static bool
configure_stream(ffado_device_t *dev, int number)
{
return ffado_streaming_set_playback_stream_buffer(dev, number, (char *)buffer) == 0 &&
ffado_streaming_playback_stream_onoff(dev, number, 1) == 0;
}

int main(int argc, char **argv) {
ffado_device_t *dev;

ffado_device_info_t device_info;
memset(&device_info, 0, sizeof(device_info));
ffado_options_t options;
memset(&options, 0, sizeof(options));
options.sample_rate = 44100;
options.period_size = PERIOD_SIZE;
options.nb_buffers = NB_BUFFERS;
options.verbose = 4;

dev = ffado_streaming_init(device_info, options);
assert(dev != NULL);

ffado_streaming_set_audio_datatype(dev, ffado_audio_datatype_float);

int num_streams = ffado_streaming_get_nb_playback_streams(dev);
assert(num_streams > 0);

int streams[MAX_STREAMS], configured_streams = 0;
for (int i = 0; i < num_streams; ++i) {
if (configured_streams >= 2)
break;

char name[256];
ffado_streaming_get_playback_stream_name(dev, i, name,
 sizeof(name) - 1);

ffado_streaming_stream_type type =
ffado_streaming_get_playback_stream_type(dev, i);
if (type != ffado_stream_type_audio)
continue;

printf("stream %d name='%s'\n", i, name);

streams[configured_streams++] = i;
configure_stream(dev, i);
}

if (ffado_streaming_prepare(dev) != 0) {
fprintf(stderr, "ffado_streaming_prepare() failed\n");
return 1;
}

if (ffado_streaming_start(dev) != 0) {
fprintf(stderr, "ffado_streaming_start() failed\n");
return 1;
}

getchar();

return 0;
}
Cannot create thread 1 Operation not permitted
ERROR: messagebuffer not initialized: 1250338856552:  (ffado.cpp)[  92] 
ffado_streaming_init: libffado 2.999.0- built Oct 16 2010 22:29:48
ERROR: messagebuffer not initialized: 1250338856611: Warning (ffado.cpp)[ 
121] ffado_streaming_init: Realtime scheduling is not enabled. This will cause 
significant reliability issues.
ERROR: messagebuffer not initialized: 1250339089620: Debug 
(devicemanager.cpp)[ 358] discover: Starting discovery...
ERROR: messagebuffer not initialized: 1250339197751: Debug (Configuration.cpp)[ 
163] showSetting:   Group: (null)
ERROR: messagebuffer not initialized: 1250339197771: Debug (Configuration.cpp)[ 
185] showSetting: vendorid = 3436 (0x0D6C)
ERROR: messagebuffer not initialized: 125033919: Debug (Configuration.cpp)[ 
185] showSetting: modelid = 65634 (0x00010062)
ERROR: messagebuffer not initialized: 1250339197783: Debug (Configuration.cpp)[ 
209] showSetting: vendorname = M-Audio
ERROR: messagebuffer not initialized: 1250339197787: Debug (Configuration.cpp)[ 
209] showSetting: modelname = FW Solo
ERROR: messagebuffer not initialized: 1250339197791: Debug (Configuration.cpp)[ 
185] showSetting: driver = 1 (0x0001)
ERROR: messagebuffer not initialized: 1250339197796: Debug (Configuration.cpp)[ 
185] showSetting: xmit_max_cycles_early_transmit = 4 (0x0004)
ERROR: messagebuffer not initialized: 1250339197885: Debug (devicemanager.cpp)[ 
620] discover: driver found for device 0
ERROR: messagebuffer not initialized: 1250339218779: Debug 
(bebob_avdevice.cpp)[ 734] loadFromCache: filename 
/home/max/.ffado/cache/000d6c0b0076ee12/006001040403.xml
ERROR: messagebuffer not initialized: 1250339224945: Debug 
(serialize_libxml.cpp)[ 230] checkVersion: Cache version: 2.999.0-, expected: 
2.999.0-.
ERROR: messagebuffer not initialized: 1250339374980: Debug (avc_unit.cpp)[ 489] 
discoverPlugConnections: Discovering PCR plug connections...
ERROR: messagebuffer not initialized: 1250339412532: Debug (avc_unit.cpp)[ 500] 
discoverPlugConnections: Discovering External plug connections...
ERROR: messagebuffer not initialized: 1250339451864: Debug 
(bebob_avdevice_subunit.cpp)[ 102] discoverConnections: Discovering 
connections...
ERROR: messagebuffer not initialized: 1250339451876: Debug (avc_subunit.cpp)[ 
148] discoverConnections: Discovering connections...
ERROR: messagebuffer not initialized: 1250339451882: Debug (avc_subunit.cpp)[ 
148] discoverConnections: Discovering connections...
ERROR: messagebuffer not initialized: 1250339451885: Debug 
(bebob_avdevice_subunit.cpp)[ 102] discoverConnections: Discovering 
connections...
ERROR: messagebuffer not initialized: 1250339451888: Debug (avc_sub

Bug#601657: libffado2 thread crashes with assertion failure

2010-10-28 Thread Max Kellermann
reopen 601657
thanks

On 2010/10/28 11:08, Adrian Knoth  wrote:
> On Thu, Oct 28, 2010 at 09:31:48AM +0200, Max Kellermann wrote:
> 
> > The attached test program can trigger a (timing?) bug in libffado2,
> 
> Welcome to userlevel device drivers. For some reasons, the packets were
> not delivered or received in time.
> 
> Might be a combination of period-size (lower is sometimes better),
> firewire controllers and so on.
> 
> As always, svn trunk might have a fix if it's really a device specific
> error, i.e. misunderstanding of the samplerate in use.
> 
> > ERROR: messagebuffer not initialized: 1250338856611: Warning
> > (ffado.cpp)[ 121] ffado_streaming_init: Realtime scheduling is not
> > enabled. This will cause significant reliability issues.
> 
> You're running it without realtime priorities? Now I see why you get
> the timing issues mentioned above.

You seem to be misunderstanding the problem here.  This is not about a
buffer xrun because the application didn't submit enough PCM samples
in time; this is about a crash due to an assertion failure, i.e. a bug
in libffado2.

Please do not close this bug report until there is a new Debian
revision which does not crash (or until there is evidence that my test
program is bugged, indirectly causing the crash).

Max



___
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-multimedia-maintainers


Bug#601657: libffado2 thread crashes with assertion failure

2010-10-28 Thread Adrian Knoth
On Thu, Oct 28, 2010 at 11:41:50AM +0200, Max Kellermann wrote:

> > > ERROR: messagebuffer not initialized: 1250338856611: Warning
> > > (ffado.cpp)[ 121] ffado_streaming_init: Realtime scheduling is not
> > > enabled. This will cause significant reliability issues.
> > 
> > You're running it without realtime priorities? Now I see why you get
> > the timing issues mentioned above.
> 
> You seem to be misunderstanding the problem here.  This is not about a
> buffer xrun because the application didn't submit enough PCM samples
> in time; this is about a crash due to an assertion failure, i.e. a bug
> in libffado2.

Oh, you're right. At least something is wrong. It's also throwing this
failed assertion on my known-to-be-working setup.

Given that jackd can successfully use libffado, it might be still your
program.

I'm CCing ffado-devel.

When I compare

   
http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=test.c;att=1;bug=601657

to the code in jackd1's drivers/firewire/ directory or to ffado's
tests/streaming/teststreaming3.cpp, I wonder if you might simply miss to
fill the buffers or to iterate/wait for FFADO.

For ffado-devel: log is at

   
http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=log;att=2;bug=601657



-- 
mail: a...@thur.de  http://adi.thur.de  PGP/GPG: key via keyserver



___
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-multimedia-maintainers


Bug#601657: libffado2 thread crashes with assertion failure

2010-10-28 Thread Max Kellermann
On 2010/10/28 13:44, Adrian Knoth  wrote:
> When I compare
> 
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=test.c;att=1;bug=601657
> 
> to the code in jackd1's drivers/firewire/ directory or to ffado's
> tests/streaming/teststreaming3.cpp, I wonder if you might simply miss to
> fill the buffers or to iterate/wait for FFADO.

It is intentionally missing.  It is a timing related bug, it triggers
only under certain circumstances.  It seems this happens when the
application does not fill the buffers quickly enough after
initialization.  I simulated that by blocking the main thread forever
with getchar().  This triggers the crash reliably.

While setting realtime may (or may not) reduce the chances to hit that
bug, it is not a solution.

When libffado2 notices that a buffer hasn't been filled in time, I
would expect it to report that error to the application, instead of
crashing.

Max



___
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-multimedia-maintainers


Bug#601657: libffado2 thread crashes with assertion failure

2010-10-28 Thread Adrian Knoth
On Thu, Oct 28, 2010 at 01:54:25PM +0200, Max Kellermann wrote:

> > When I compare
> > 
> >
> > http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=test.c;att=1;bug=601657
> > 
> > to the code in jackd1's drivers/firewire/ directory or to ffado's
> > tests/streaming/teststreaming3.cpp, I wonder if you might simply miss to
> > fill the buffers or to iterate/wait for FFADO.
> 
> It is intentionally missing.  It is a timing related bug, it triggers

> When libffado2 notices that a buffer hasn't been filled in time, I
> would expect it to report that error to the application, instead of
> crashing.

Ah, now I get it.

If you compile with DEBUG=0, then assert() is a NOP and your test
program finishes cleanly:

2145932376749: Warning (IsoHandlerManager.cpp)[ 282] Execute: Timeout while 
waiting for activity
2145933300504: Fatal (IsoHandlerManager.cpp)[ 338] Execute: (0x993d2d8, 
Receive) Handler died: now: 4D7DE6B8, last: 497BF381, diff: 49248055 (max: 
49152000)
2145933300551: Warning (StreamProcessor.cpp)[ 126] handlerDied: Handler died 
for 0x993b8c8
2145934300663: Warning (IsoHandlerManager.cpp)[ 282] Execute: Timeout while 
waiting for activity
2145934310756: Fatal (IsoHandlerManager.cpp)[ 338] Execute: (0x993d1a8, 
Transmit) Handler died: now: 4F83093E, last: 49654344, diff: 75191802 (max: 
49152000)
2145934310785: Warning (StreamProcessor.cpp)[ 126] handlerDied: Handler died 
for 0x993c130

no message buffer overruns


So I guess it's me to blame for shipping a DEBUG-enabled FFADO version
in Debian. OTOH, this was intended: http://bugs.debian.org/572141

We should probably come up with a clean solution, so we have both
versions in Debian.

Can you confirm that test.c doesn't trigger the bug when ffado is
compiled without DEBUG?


TIA

-- 
mail: a...@thur.de  http://adi.thur.de  PGP/GPG: key via keyserver



___
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-multimedia-maintainers


Bug#601657: libffado2 thread crashes with assertion failure

2010-11-04 Thread Max Kellermann
On 2010/10/28 15:46, Adrian Knoth  wrote:
> Can you confirm that test.c doesn't trigger the bug when ffado is
> compiled without DEBUG?

Confirmed.  The package 2.0.1+svn1856-6 hides the symptoms of the bug.

(The bug is of course still present, and needs to be fixed)

Max



___
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-multimedia-maintainers


Processed: Re: Bug#601657: libffado2 thread crashes with assertion failure

2010-10-28 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

> reopen 601657
Bug #601657 {Done: Adrian Knoth } [libffado2] 
libffado2 thread crashes with assertion failure
> thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
601657: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=601657
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems

___
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-multimedia-maintainers