phandasm / waveform

Audio spectral analysis plugin for OBS
https://obsproject.com/forum/resources/waveform.1423/
GNU General Public License v3.0
512 stars 35 forks source link

Segfault with "Normalize Volume" and AVX2 #34

Closed fzwoch closed 1 year ago

fzwoch commented 1 year ago

Happened when ticking the Normalize Volume checkbox.

_mm256_store_ps(&m_decibels[channel][i], _mm256_add_ps(volume_compensation, _mm256_load_ps(&m_decibels[channel][i])));
#0  0x00007fff8536bed4 in _mm256_load_ps(float const*) (__P=0x7fff89539464) at /usr/lib/gcc/x86_64-linux-gnu/12/include/avxintrin.h:881
#1  WAVSourceAVX2::tick_spectrum(float) (this=0x555557386150, seconds=0.0166666657) at /home/fzwoch/code/waveform/src/source_avx2.cpp:192
#2  0x00007fff85361516 in WAVSource::tick(float) (this=0x555557386150, seconds=0.0166666657) at /home/fzwoch/code/waveform/src/source.cpp:1051
#3  0x00007fff8535d20f in callbacks::tick(void*, float) (data=0x555557386150, seconds=0.0166666657) at /home/fzwoch/code/waveform/src/source.cpp:389
#4  0x00007ffff677a41d in obs_source_video_tick () at /usr/local/lib/libobs.so.0
#5  0x00007ffff6784c02 in obs_graphics_thread_loop () at /usr/local/lib/libobs.so.0
#6  0x00007ffff6786e48 in obs_graphics_thread () at /usr/local/lib/libobs.so.0
#7  0x00007ffff4aa7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
``` (gdb) info locals i = 1 channel = 0 volume_compensation = {30, 30, 30, 30, 30, 30, 30, 30} bufsz = 16384 outsz = 2048 step = 8 dtsize = 3196 silent_channels = 0 ``` ``` (gdb) p *this $12 = { = { = { = {_vptr.WAVSource = 0x7fff8537fc98 , m_mtx = { = {_M_mutex = {__data = {__lock = 2, __count = 1, __owner = 26529, __nusers = 1, __kind = 1, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = "\002\000\000\000\001\000\000\000\241g\000\000\001\000\000\000\001", '\000' , __align = 4294967298}}, > = {}, }, m_source = 0x555557409d40, m_audio_source = 0x55555739a9e0, m_audio_source_name = "Desktop Audio", m_audio_info = { samples_per_sec = 48000, speakers = SPEAKERS_STEREO}, m_capturebufs = {{data = 0x5555576c43a0, size = 17988, start_pos = 3196, end_pos = 21184, capacity = 32768}, {data = 0x555557701350, size = 17988, start_pos = 3196, end_pos = 21184, capacity = 32768}}, m_capture_channels = 2, m_output_channels = 2, m_output_bus_captured = false, m_fft_input = std::unique_ptr = {get() = 0x7fff8957a1e0}, m_fft_output = std::unique_ptr = {get() = 0x7fff89562060}, m_fft_plan = 0x7fff89579ca0, m_window_coefficients = std::unique_ptr = {get() = 0x7fff8956a0a0}, m_tsmooth_buf = {std::unique_ptr = {get() = 0x7fff895732a0}, std::unique_ptr = {get() = 0x7fff89577340}}, m_decibels = {std::unique_ptr = {get() = 0x7fff89539460}, std::unique_ptr = {get() = 0x7fff895752e0}}, m_fft_size = 4096, m_meter_pos = {0, 0}, m_meter_val = {0, 0}, m_meter_buf = {0, 0}, m_meter_rms = true, m_meter_mode = false, m_meter_ms = 150, m_fps = 60, m_width = 1350, m_height = 225, m_show = true, m_last_silent = false, m_retries = 0, m_next_retry = 0, m_render_mode = RenderMode::SOLID, m_window_func = FFTWindow::BLACKMAN_HARRIS, m_interp_mode = InterpMode::LANCZOS, m_filter_mode = FilterMode::NONE, m_tsmoothing = TSmoothingMode::EXPONENTIAL, m_display_mode = DisplayMode::BAR, m_stereo = true, m_auto_fft_size = false, m_cutoff_low = 30, m_cutoff_high = 17500, m_floor = -65, m_ceiling = 0, m_gravity = 0.649999976, m_grad_ratio = 0.75, m_fast_peaks = false, m_color_base = {{{x = 1, y = 1, z = 1, w = 1}, ptr = {1, 1, 1, 1}, m = {1, 1, 1, 1}}}, m_color_crest = {{{x = 1, y = 1, z = 1, w = 1}, ptr = {1, 1, 1, 1}, m = {1, 1, 1, 1}}}, m_slope = 0, m_log_scale = true, m_mirror_freq_axis = false, m_bar_width = 7, m_bar_gap = 6, m_step_width = 8, m_step_gap = 4, m_num_bars = 104, m_radial = false, m_invert = false, m_deadzone = 0, m_radial_arc = 1, m_rounded_caps = false, m_hide_on_silent = false, m_channel_spacing = 2, m_rolloff_q = 0, m_rolloff_rate = 0, m_normalize_volume = true, m_min_bar_height = 2, m_interp_indices = std::vector of length 105, capacity 105 = { 2.55999994, 2.72166896, 2.89354801, 3.07628107, 3.27055454, 3.47709656, 3.69668198, 3.93013477, 4.17833042, 4.44220066, 4.72273445, 5.02098417, 5.33806944, 5.67517853, 6.03357792, 6.41460991, 6.81970549, 7.25038338, 7.70825958, 8.19505119, 8.71258545, 9.26280212, 9.84776688, 10.4696722, 11.1308527, 11.8337879, 12.5811157, 13.375639, 14.2203379, 15.1183786, 16.0731335, 17.0881863, 18.1673393, 19.31464, 20.534399, 21.8311863, 23.2098694, 24.6756172, 26.2339325, 27.8906593, 29.6520119, 31.5245934, 33.5154305, 35.632, 37.8822289, 40.2745705, 42.8179817, 45.5220261, 48.3968353, 51.4531937, 54.7025566, 58.1571312, 61.8298759, 65.7345428, 69.8858261, 74.2992477, 78.9914093, 83.9798584, 89.2833405, 94.9217834, 100.916267, 107.289314, 114.06488, 121.26828, 128.926651, 137.068604, 145.724731, 154.927582, 164.711533, 175.113434, 186.172165, 197.929276, 210.428955, 223.717926, 237.84613, 252.866638, 268.835632, 285.813202, 303.862823, 323.052307, 343.453796, 365.143555, 388.203156, 412.718903, 438.782837, 466.49295, 495.95285, 527.273193, 560.571655, 595.972778, 633.609802, 673.623413, 716.16394, 761.391296, 809.474609, 860.594666, 914.942871, 972.723206, 1034.15283, 1099.46143, 1168.89441, 1242.71265, 1321.19226, 1404.62854, 1493.33337}, m_interp_bufs = {std::vector of length 104, capacity 104 = {109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5}, std::vector of length 104, capacity 104 = {109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5, 109.5}, std::vector of length 104, capacity 104 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, m_rolloff_modifiers = std::unique_ptr = {get() = 0x0}, m_kernel = {weights = std::unique_ptr = {get() = 0x0}, radius = 0, size = 0, sse_size = 0, sum = 0}, m_filter_radius = 1.5, m_slope_modifiers = std::unique_ptr = {get() = 0x7fff895802a0}, m_cap_radius = 0, m_cap_tris = 4, m_cap_verts = std::vector of length 0, capacity 0, m_step_verts = std::vector of length 0, capacity 0, m_shader = 0x555557402e60, m_vbuf = 0x5555574da860, m_input_rms = 0.000682700833, m_input_rms_buf = std::unique_ptr = {get() = 0x7fff89584140}, m_input_rms_size = 48000, m_input_rms_pos = 1200, static DB_MIN = -758.595581, static RETRY_DELAY = 2, static HAVE_AVX2 = true, static HAVE_AVX = true, static HAVE_FMA3 = true}, }, }, } ```
phandasm commented 1 year ago

Oops, silly mistake. And naturally it escapes detection because MSVC refuses to emit vmovaps for any reason.

Let me know if 1.6.0-beta2 fixes it: https://github.com/phandasm/waveform/releases/tag/v1.6.0-beta2

fzwoch commented 1 year ago

Yep, it is fixed with latest master, thanks!