xiph / rnnoise

Recurrent neural network for audio noise reduction
BSD 3-Clause "New" or "Revised" License
4.1k stars 896 forks source link

Use asserts instead of segfaults #118

Open nicolasbrailo opened 4 years ago

nicolasbrailo commented 4 years ago

I noticed some places try to crash the application using

(int)0 = 0;

Is there a reason not to use assert(1) from the std lib?

$ grep -nri '\*(int' src/rnn.c:99: *(int*)0 = 0; src/rnn.c:145: *(int*)0 = 0;

wegylexy commented 4 years ago

When targeting environments such as WASM with no standard libraries at all, terminating functions (e.g. assert(), abort(), exit()) require implementations at run-time. Since the trap is a debugging utility, it would better be a no-op (or something that compiles to unreachable in WASM to throw out to the JavaScript run-time) than linking in more code that never runs.

wegylexy commented 4 years ago

See https://github.com/scottt/debugbreak

wegylexy commented 4 years ago

This seems to be a duplicate of #6 .