nikp123 / xava

X11 Audio Visualizer for ALSA
http://nikp123.github.io/xava
Other
134 stars 15 forks source link

Segmentation fault #12

Closed takase1121 closed 4 years ago

takase1121 commented 4 years ago

This is another error from the AUR package xava-git.

(gdb) run
Starting program: /usr/bin/xava 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff6b1a700 (LWP 6770)]
[New Thread 0x7ffff6319700 (LWP 6782)]
[New Thread 0x7ffff5b18700 (LWP 6783)]
[New Thread 0x7ffff4a57700 (LWP 6788)]
[New Thread 0x7fffcfafd700 (LWP 6789)]
[New Thread 0x7fffcf2fc700 (LWP 6790)]
[New Thread 0x7fffceafb700 (LWP 6791)]
[New Thread 0x7fffce2fa700 (LWP 6792)]
[New Thread 0x7fffcdaf9700 (LWP 6793)]
[New Thread 0x7fffcd2f8700 (LWP 6794)]
[New Thread 0x7fffccaf7700 (LWP 6795)]
[New Thread 0x7fffaffff700 (LWP 6796)]
[New Thread 0x7fffaf7fe700 (LWP 6797)]
[New Thread 0x7fffaeffd700 (LWP 6798)]
[New Thread 0x7fffae7fc700 (LWP 6799)]
[New Thread 0x7fffadffb700 (LWP 6800)]
[New Thread 0x7fffad7fa700 (LWP 6801)]
[New Thread 0x7fffacff9700 (LWP 6802)]

Thread 1 "xava" received signal SIGSEGV, Segmentation fault.
0x00007ffff76cc2e5 in __strlen_avx2 () from /usr/lib/libc.so.6

I suspect that it has something to do with config files, but I could be entirely wrong :)

nikp123 commented 4 years ago

Thank you for reporting these issues. Could you give me the config file for testing? I've did some backend memory management changes and this could be the result of them.

nikp123 commented 4 years ago

Also note: It shouldn't crash under any "normal" conditions, this is most definitely a bug (just not confirmed yet).

takase1121 commented 4 years ago

The config file is generated by the program when starting it for the first time. I didn't change it. Here is it just in case:

## Configuration file for XAVA. Default values are commented out. Use either ';' or '#' for commenting.

[general]

# Accepts only non-negative values.
; framerate = 60

# Keep the application in sync with the monitor to prevent tearing
# It's generally recommended to keep it on, as different framerates may lead to unstable frametimes
# -1 = adaptive Vsync (G-Sync. FreeSync, etc.)
# 0 = off
# 1 up to refresh rate = refresh at the refresh rate of the monitor divided by the number given
; vsync = 1

# 'autosens' will attempt to balance the sensitivity to keep the amplitude of the bars 
# within a reasonable range
; autosens = true

# Manual sensitivity in %. Autosens must be turned off for this to take effect.
# 200 means double height and so on. Accepts only non-negative values.
; sensitivity = 100

# The number of bars. 0 sets it to auto (put as many as you can).
# Bars' width and space between bars in number of pixels on screen.
; bars = 0
; bar_width = 13
; bar_spacing = 5

# Lower and higher cutoff frequencies for lowest and highest bars
# the bandwidth of the visualizer.
# XAVA will automatically increase the higher cutoff if a too low band is specified.
; lower_cutoff_freq = 26
; higher_cutoff_freq = 15000

[window]

# Window width and height
; width = 1180
; height = 300

# Fullscreen toggle
; fullscreen = false

# Enables or disables window borders 
; border = false

# Window transparency toggle (your system must support transparent windows)
; transparency = true

# Keeps the window under any other (doesn't work in SDL)
; keep_below = true

# This option aligns the window with a certain part of the screen
# The following positions are supported:
# top_left, top, top_right, left, center, right, bottom_left,
# bottom, bottom_right and none if you don't want manual positioning
; alignment = 'none'

# Additionally we can further adjust the position if needed (in pixels)
# It moves the window the opposite direction of whats in alignment
# FXP. if alignment is set to right and x_padding is 20, 
# it will move the window left 20 pixels and so on for every direction 
; x_padding = 0
; y_padding = 0

# Enables the OpenGL renderer (not available on all output modes)
; opengl = 1

# This option removes the ability to interact with the window
# NOTE: It does not work with SDL2 
; interactable = 1

# Create an taskbar icon
; taskbar_icon = 1

# Draw directly on the root window (or wallpaper) itself (Xorg ONLY), VERY UNPREDICTABLE
# You need to stop any form of compositing for this to even work properly
; rootwindow = 0

[input]

# Audio capturing method. Possible methods are the ones listed below.
# If one doesn't work, it might not be supported by your system or it just wasn't compiled with it.
# 
# Defaults to the order shown below ('pulse', 'portaudio', 'alsa'...)
#
# All input methods uses the same config variable 'source'
# to define where it should get the audio.
#
# For pulseaudio 'source' will be the source. Default: 'auto', which uses the monitor source of the default sink
# (all pulseaudio sinks(outputs) have 'monitor' sources(inputs) associated with them).
# 
# For alsa, wasapi and portaudio 'source' will be the capture device.
# For fifo 'source' will be the path to fifo-file.
#
# In case of wasapi, specify 'loopback' to capture audio from the system or anything else 
# to capture from an input device, such as a microphone
#
# You can also specify 'list' as the source to portaudio to list all available audio devices
; method = pulse
; source = auto

; method = portaudio
; source = auto

; method = alsa
; source = hw:Loopback,1

; method = sndio
; source = 

; method = shmem
; source = /squeezelite-00:00:00:00:00:00 

; method = fifo
; source = /tmp/mpd.fifo

; method = wasapi
; source = loopback

[output]

# Output method. Can be any of the following (if supported):
# By default it's the window that is recommended for your platform/OS.
# 'sdl' is for a graphical window using SDL2
# 'x11' is for a graphical window using X11 (usually faster, unsupported in wayland however)
# 'win' is for a win32 graphical window
; method = x11

# Visual channels. Can be 'stereo' or 'mono'.
# 'stereo' mirrors both channels with low frequencies in center.
# 'mono' averages both channels and outputs left to right lowest to highest frequencies.
; channels = mono

[color]

# Colors can be one of seven predefined: black, blue, cyan, green, magenta, red, white, yellow.
# Or defined by hex code '#xxxxxx' (hex code must be within '').
# It can also be 'default' at which point under X11 it reads the color off of Xrdb
# Under Windows it uses your system accent color
# And on SDL2 it's just black and cyan (default colorscheme)
; background = default
; foreground = default

# This adjusts the opacity of the bars (must have transparency and OpenGL in order for it to work)
; foreground_opacity = 1.0

# And this does the same but for the background (previous rule applies here as well) 
; background_opacity = 0.0

# Gradient mode, only hex defined colors are supported, background must also be defined in hex
# or remain commented out.
# To enable gradients, just change gradient_count to the number of colors you have specified
# (0 = disabled)
; gradient_count = 0
; gradient_color_1 = '#0099ff'
; gradient_color_2 = '#ff3399'

[smoothing]

# Percentage value for integral smoothing. Takes values from 0 - 100.
# Higher values means smoother, but less precise. 0 to disable.
; integral = 85

# Disables or enables the so-called "Monstercat smoothing" with or without "waves". Set to 0 to disable. 
; monstercat = 1.2
; waves = 0

# Set gravity percentage for "drop off". Higher values means bars will drop faster.
# Accepts only non-negative values. 50 means half gravity, 200 means double. Set to 0 to disable "drop off".
; gravity = 100

# In bar height, bars that would have been lower that this (in pixels) will not be drawn.
; ignore = 0

# Adjust the logarithmic scale of the frequency band (the lower the value, 
# the less difference between bars in frequency)
; log = 1.55

# Average out the value of each odd bar (just like the monstercat visualizer)
; oddoneout = true

# Balances the eq towards higher or lower frequencies
# lower value->lower frequencies, higher value->higher frequencies
; eq_balance = 0.67

# Adjusts the input buffer size (in samples, calculated by 2^input_size)
; input_size = 12

# Adjusts the FFT buffer size (calculated by 2^fft_size)
; fft_size = 14

[shadow]

# Fake shadow effect (works with transparency only)
# To disable shadows, set size to 0
; size = 7

# Color format is #aarrggbb
; color = "#ff000000"

[eq]

# This one is tricky. You can have as much keys as you want.
# Remember to uncomment more then one key! More keys = more precision.
# Look at readme.md on github for further explanations and examples.
; 1 = 1 # bass
; 2 = 1
; 3 = 1 # midtone
; 4 = 1
; 5 = 1 # treble
takase1121 commented 4 years ago

In case there may be invisible character, this is the raw file:

config.txt

nikp123 commented 4 years ago

Nope, seems to work just fine on my machine(TM)

Could you recompile with debug features enabled:

git clone https://github.com/nikp123/xava
mkdir xava/build
cd xava/build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j$(nproc)
gdb ./xava
r
(when it crashes do: bt)

And return the result

takase1121 commented 4 years ago
Thread 1 "xava" received signal SIGSEGV, Segmentation fault.
0x00007ffff76cc2e5 in __strlen_avx2 () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff76cc2e5 in __strlen_avx2 () from /usr/lib/libc.so.6
#1  0x00007ffff7d4318a in ?? () from /usr/lib/libX11.so.6
#2  0x00007ffff7d45eed in XrmGetStringDatabase () from /usr/lib/libX11.so.6
#3  0x000055555555b150 in calculateColors () at /home/takase/gh/xava/src/output/graphical_x.c:117
#4  0x000055555555b658 in init_window_x () at /home/takase/gh/xava/src/output/graphical_x.c:172
#5  0x0000555555562c50 in main (argc=1, argv=0x7fffffffe058) at /home/takase/gh/xava/src/xava.c:412

@nikp123

takase1121 commented 4 years ago

https://github.com/nikp123/xava/blob/6cc99e7ac1e8caa12c6b67fd4abb0dace1d611b5/src/output/graphical_x.c#L117

According to some docs I found, I think there are two possibilities (Don't quote me on this, I am not a C/C++ dev nor do I know Xlib):

  1. calculateColors is called before Display is initialized (almost impossible)
  2. XResourceManagerString returns NULL which breaks XrmGetStringDatabase()
takase1121 commented 4 years ago

According some random docs I found again

Most X clients use the RESOURCE_MANAGER and SCREEN_RESOURCES properties to get user preferences about color, fonts, and so on for applications. Having this information in the server (where it is available to all clients) instead of on disk, solves the problem in previous versions of X that required you to maintain defaults files on every machine that you might use. It also allows for dynamic changing of defaults without editing files.

This might actually be the reason. I use dwm which I think doesn't tamper with X resources. I still have no clue about the exact location though.

nikp123 commented 4 years ago

Looking at your suggestions, I guess that you're completely right. A NULL value would probably crash the entire thing. Will need to replicate this setup somehow first.

nikp123 commented 4 years ago

Replicating setup in Xephyr confirms crash.

nikp123 commented 4 years ago

I've pushed a commit that hopefully resolves this. Test it out.

takase1121 commented 4 years ago

Nice! I'll try it out tomorrow. Already shut down my laptop.

takase1121 commented 4 years ago

Confirm issue fixed. Closing this issue.