Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 1223 - Click Track causes Audacity to crash when creating very many clicks
Click Track causes Audacity to crash when creating very many clicks
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Nyquist
2.1.2
Per OS macOS and Linux
: P4 Repeatable
Assigned To: Default Assignee for New Bugs
: nyquist
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-02 10:30 UTC by Steve Daulton
Modified: 2018-08-20 11:45 UTC (History)
8 users (show)

See Also:
Steps To Reproduce:
Generate a click track with the following settings: Beats per measure: 20 (maximum) Number of measures: 1000 (maximum) Click OK then wait... Audacity crashes.
Release Note:
First Git SHA:
Group: ---
Workaround:
Closed: 2018-08-20 00:00:00


Attachments
gdb backtrace from Ubuntu 14.04 (7.12 KB, text/plain)
2016-06-22 12:55 UTC, Gale Andrews
Details
Fix clicktrack.ny to use lazy evaluation (1.84 KB, patch)
2016-06-22 16:41 UTC, Roger Dannenberg
Details | Diff
Here's the whole plug-in, modified to use lazy evaluation (10.10 KB, text/plain)
2016-06-22 16:42 UTC, Roger Dannenberg
Details
New stack trace on Ubuntu 14.04 (5.47 KB, text/plain)
2016-06-24 11:10 UTC, Gale Andrews
Details
Mac crash report for the lazy_evaluation version of Click Track (9.11 KB, text/plain)
2016-06-24 11:11 UTC, Gale Andrews
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Daulton 2015-10-02 10:30:57 UTC
See steps to reproduce.

The problem occurs with Debug build on Debian Stable (Jessie). Not yet tested with a release build on Linux. The problem does not occur with Oct 1st Nightly on Windows XP running in Virtualbox.

If the "SEQ" command is removed from near the end of clicktrack.ny, the plug-in completes generating the click track without crashing, but then does not have the final silence for the last beat, and does not have the start offset.

To do this, replace the lines:

;add time offset and beatlen of silence to clicktrack,
(seq (s-rest offset) ;offset
  (cue clicktrack) ;click track
  (s-rest(- beatlen ticklen)))) ;trailing silence

with a single close bracket.

The SEQ command appears to work normally in other contexts.

It may be possible to work around this problem by writing the plug-in differently, but I don't yet see why this problem is occurring, or why it occurs on my Linux build but not the Windows Nightly.
Comment 1 Steve Daulton 2015-10-02 11:17:29 UTC
(In reply to Steve Daulton from comment #0)
The crash also occurs in a release build (preferences reset to default).
Comment 2 Gale Andrews 2015-10-02 23:06:56 UTC
Windows does not crash (real hardware) but El Capitan and Ubuntu 14.04 32-bit both crash at these 12000 beats combinations:  Beats 12 / Measures 1000, Beats 15 /  Measures 800 or Beats 20 / Measures 600. 

8000 beats does not crash.

I think it's close to P3 but probably not quite there, assuming > 8 beats per measure is unusual. 4 Beats / 3000 Measures also crashes, but you have to modify the plugin to try that.
Comment 3 Steve Daulton 2015-10-03 07:45:42 UTC
(In reply to Gale Andrews from comment #2)
> assuming > 8 beats per measure is unusual
More than 8 beats per bar may not be unusual. If the user wants to practice quaver passages in 4/4 they may well want 16 clicks per bar.

More than 100 bars is probably unusual.

Is this a regression against previous releases?
Comment 4 Steve Daulton 2015-10-03 07:47:28 UTC
(In reply to Steve Daulton from comment #3)
"semiquaver"
Comment 5 Gale Andrews 2015-10-04 02:10:44 UTC
(In reply to Steve Daulton from comment #3)
> Is this a regression against previous releases?
2.1.1 Release on Linux crashes the same, so it is not the most serious type of regression on that "measure".
Comment 6 Paul L 2016-06-21 17:19:26 UTC
This crashed because of stack overflow in libnyquist code.  It ought to be reproducible on Windows too, with a long enough click track.

Stack on Mac contained:

#174368	0x006d6ac3 in snd_list_unref at /Users/paullicameli/GitHub/audacity/lib-src/libnyquist/nyquist/nyqsrc/sound.c:533
#174369	0x006d6ac3 in snd_list_unref at /Users/paullicameli/GitHub/audacity/lib-src/libnyquist/nyquist/nyqsrc/sound.c:533
#174370	0x006d6ac3 in snd_list_unref at /Users/paullicameli/GitHub/audacity/lib-src/libnyquist/nyquist/nyqsrc/sound.c:533
#174371	0x006d68e7 in sound_unref at /Users/paullicameli/GitHub/audacity/lib-src/libnyquist/nyquist/nyqsrc/sound.c:477
#174372	0x006d8b77 in sound_xlfree at /Users/paullicameli/GitHub/audacity/lib-src/libnyquist/nyquist/nyqsrc/sound.c:1609
#174373	0x00772d18 in sweep at /Users/paullicameli/GitHub/audacity/lib-src/libnyquist/nyquist/xlisp/xldmem.c:511
#174374	0x0077262e in gc at /Users/paullicameli/GitHub/audacity/lib-src/libnyquist/nyquist/xlisp/xldmem.c:344
#174375	0x006903c1 in nyx_get_audio at /Users/paullicameli/GitHub/audacity/lib-src/libnyquist/nyx.c:1063
#174376	0x001017db in NyquistEffect::ProcessOne() at /Users/paullicameli/GitHub/audacity/src/effects/nyquist/Nyquist.cpp:1182
#174377	0x000fcce7 in NyquistEffect::Process() at /Users/paullicameli/GitHub/audacity/src/effects/nyquist/Nyquist.cpp:698

And many repetitions of snd_list_unref above that until exhaustion.
Comment 7 Paul L 2016-06-21 17:54:49 UTC
Fixed at https://github.com/audacity/audacity/commit/8ad9fd257c6a90313d87dab8c4bf803a945b7076

but we need to tell Roger to push it upstream to Nyquist.
Comment 8 Peter Sampson 2016-06-22 11:21:05 UTC
Tests ok on W10 audacity-win-r3410b60-2.1.3-alpha-22-jun-16

But part way through I did get a warning message to say it wasn't responding but thn it just carried on and completed
Comment 9 Paul L 2016-06-22 12:36:44 UTC
I say mark the crash bug as fixed.

The lenghty calculation that makes the application unreponsive is just life.
Comment 10 Gale Andrews 2016-06-22 12:54:34 UTC
OK for me too on Windows 10 but steps still crash for me on El Capitan and Ubuntu 14.04 at https://github.com/audacity/audacity/commit/56acdf6 (release builds in both cases, I made distclean in both cases). 

On Mac I saw no progress dialogue for Click Track, on Linux I did. In both cases the Audacity Debug Report was generated. I have attached the Ubuntu 14.04 backtrace assuming that will be more use.     

Roger is already on the Cc list for this bug.
Comment 11 Gale Andrews 2016-06-22 12:55:09 UTC
Created attachment 682 [details]
gdb backtrace from Ubuntu 14.04
Comment 12 Paul L 2016-06-22 13:13:16 UTC
I know it crashed with a stack overflow before on my MacbookPro, and now it does not.

But the stack trace suggests that there is another deep recursion happening during the evaluation of the sound.  Perhaps my stack space is enough not to overflow, and Gale's isn't.

A similar code transformation exercise might fix this.  But it is less obvious how to handle these mutually recursive functions.  The fix I wrote just involved one self-recursive function.
Comment 13 Roger Dannenberg 2016-06-22 15:35:15 UTC
I finally took a look at the click track code -- it puts the entire click track in Nyquist memory, so yes, long click tracks are going to allocate a lot of memory and if you don't have enough RAM, there will be a lot of swapping to disk. I'm working on a rewrite.
Comment 14 Paul L 2016-06-22 15:56:25 UTC
The fix was redone here, to be exactly as Roger rewrote it:
https://github.com/audacity/audacity/commit/ba1b63a4352c3c6cab3ef716fded14fe3c11c064

I doubt this fixes Gale's latest crash, but try it.
Comment 15 Roger Dannenberg 2016-06-22 16:41:48 UTC
Created attachment 683 [details]
Fix clicktrack.ny to use lazy evaluation
Comment 16 Roger Dannenberg 2016-06-22 16:42:41 UTC
Created attachment 684 [details]
Here's the whole plug-in, modified to use lazy evaluation
Comment 17 Roger Dannenberg 2016-06-22 16:46:07 UTC
clicktrack.ny was pretty simple to modify to avoid accumulating samples in Nyqvist -- I don't really have a good way to test this claim, and I was surprised that the (stats) function does not seem to generate output to Audacity. In any case, this runs about 25% faster than the previous version on my machine, and it does not crash (but neither does the old version). It would be nice for someone to test on a machine that had problems, even if the problems were just running slowly, and see what happens.
Comment 18 Gale Andrews 2016-06-24 11:09:21 UTC
(In reply to Paul L from comment #14)
> The fix was redone here, to be exactly as Roger rewrote it:
> https://github.com/audacity/audacity/commit/ba1b63a
>
> I doubt this fixes Gale's latest crash, but try it.
Testing at that commit, it does not fix the steps to reproduce on Ubuntu 14.04 netbook (1 GB RAM), either with the shipped Click Track or Roger's lazy_evaluation version. The stack track (attached, "bug_1223_gdb_240616.txt") is similar to before but does not have repeated  
in add_s1_nn_fetch (), in SND_get_first (), in SND_get_next ().

On El Capitan (4 GB RAM), there is now no crash with the shipped Click Track but the lazy_evaluation version crashes every time, see attached "bug_1223_lazy_eval_mac_240616.txt".

On Windows 10, I do not receive a crash with either the shipped or lazy_evaluation plugin, but the lazy one is twice as quick.
Comment 19 Gale Andrews 2016-06-24 11:10:25 UTC
Created attachment 688 [details]
New stack trace on Ubuntu 14.04
Comment 20 Gale Andrews 2016-06-24 11:11:11 UTC
Created attachment 689 [details]
Mac crash report for the lazy_evaluation version of Click Track
Comment 21 Paul L 2016-06-24 11:16:20 UTC
My guess from the stack is a dangling pointer somewhere from a failure to increase a reference count... Roger?
Comment 22 Paul L 2016-06-26 10:13:51 UTC
Thank you James for catching a silly mistake that escaped me and Roger!
https://github.com/audacity/audacity/commit/016919a53bb8f17de2a9070fbe84ed88fb27e175

Try it again, Gale.
Comment 23 Gale Andrews 2016-06-26 15:58:37 UTC
I tried the released Click Track and the faster, lazy version several times on El Capitan (Mac Mini) and Ubuntu 14.04 (netbook) and there were no crashes. And it was still OK on Windows. 

So RESOLVED - FIX and thanks to James.