Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Dereferencing NULL when using an undefined battery animation #3043

Closed
5 tasks done
d4ilyrun opened this issue Nov 16, 2023 · 2 comments
Closed
5 tasks done

[Bug]: Dereferencing NULL when using an undefined battery animation #3043

d4ilyrun opened this issue Nov 16, 2023 · 2 comments

Comments

@d4ilyrun
Copy link

d4ilyrun commented Nov 16, 2023

Checklist

  • I have read the appropriate section in the contributing guidelines
  • I believe this issue is a problem with polybar itself and not a misconfiguration on my part
  • I have searched for other open and closed issues that may have already reported this problem
  • I have checked the known issues page for this problem.
  • I have followed the debugging guide to narrow down the problem to a minimal config.

Steps to reproduce

  1. Do not define the content of discharging_label
  2. Use the discharging_animation label inside a format field
  3. polybar -c <bar_config>

Minimal config

[module/battery]
adapter=ACAD
animation-charging-0=
animation-charging-1=
animation-charging-2=
animation-charging-3=
animation-charging-4=
animation-charging-framerate=750
animation-low-0=
animation-low-1=" "
animation-low-framerate=200
battery=BAT1
format-charging=<animation-charging> <label-charging>
format-charging-foreground=#89DCEB
format-charging-underline=#89DCEB
format-discharging=<ramp-capacity> <label-discharging>
format-discharging-foreground=#89DCEB
format-discharging-underline=#89DCEB
format-full= <label-full>
format-full-foreground=#89DCEB
format-full-underline=#89DCEB
format-low=<animation-discharging> <label-low>
full-at=99
label-charging=%percentage%%
label-discharging=%percentage%%
label-full=Full
label-low=BATTERY LOW
label-low-foreground=#F28FAD
label-low-underline=#F28FAD
low-at=15
ramp-capacity-0=
ramp-capacity-1=
ramp-capacity-2=
ramp-capacity-3=
ramp-capacity-4=
type=internal/battery

Polybar log

polybar|notice:  Parsing config file: /home/leo/.config/polybar/config.ini
polybar|notice:  Listening for IPC messages (PID: 31614)
polybar|notice:  Loading module 'nixos' of type 'custom/text'
polybar|notice:  Loading module 'i3' of type 'internal/i3'
polybar|error: Disabling module "i3" (reason: No built-in support for 'internal/i3')
polybar|notice:  Loading module 'xwindow' of type 'internal/xwindow'
polybar|notice:  Loading module 'mpris-tail' of type 'custom/script'
polybar|notice:  Loading module 'kb' of type 'internal/xkeyboard'
polybar|warn:  The config parameter `module/kb.label-indicator` is deprecated, use `module/kb.label-indicator-on` instead.
polybar|notice:  Loading module 'pulseaudio' of type 'internal/pulseaudio'
polybar|error: Disabling module "pulseaudio" (reason: No built-in support for 'internal/pulseaudio')
polybar|error: Disabling module "alsa" (reason: Missing section "module/alsa")
polybar|notice:  Loading module 'battery' of type 'internal/battery'
polybar|notice:  Loading module 'wireless-network' of type 'internal/network'
polybar|notice:  Loading module 'filesystem' of type 'internal/fs'
polybar|notice:  Loading module 'date' of type 'internal/date'
polybar|notice:  Loaded 8 modules
polybar|notice:  Loaded font "Iosevka:size=13" (name=Iosevka, offset=1, file=/nix/store/z584w3rd81mfigbr8m3v06kyv21dh7wm-home-manager-path/share/fonts/truetype/iosevka-regular.ttf)
polybar|notice:  Loaded font "Iosevka:size=6" (name=Iosevka, offset=1, file=/nix/store/z584w3rd81mfigbr8m3v06kyv21dh7wm-home-manager-path/share/fonts/truetype/iosevka-regular.ttf)
polybar|notice:  Loaded font "Unifont:style=Regular,Regular:size=13" (name=Unifont, offset=0, file=/nix/store/z584w3rd81mfigbr8m3v06kyv21dh7wm-home-manager-path/share/fonts/opentype/unifont.otf)
polybar|notice:  Loaded font "Font Awesome 5 Free Solid:style=Solid:size=12" (name=DejaVu Sans, offset=0, file=/nix/store/7370cbzds0g83pn2v298ksq39xprnrhj-dejavu-fonts-2.37/share/fonts/truetype/DejaVuSans.ttf)
polybar|notice:  Loaded font "Font Awesome 5 Brands Regular:style=Regular:size=12" (name=DejaVu Sans, offset=0, file=/nix/store/7370cbzds0g83pn2v298ksq39xprnrhj-dejavu-fonts-2.37/share/fonts/truetype/DejaVuSans.ttf)
polybar|notice:  Loaded font "Material Design Icons:style=Solid:size=13" (name=Material Design Icons, offset=0, file=/nix/store/z584w3rd81mfigbr8m3v06kyv21dh7wm-home-manager-path/share/fonts/truetype/materialdesignicons-webfont.ttf)
polybar|notice:  Loaded font "Fira Code Nerd Font:style=Retina,Regular:size=13" (name=FiraCode Nerd Font, offset=0, file=/nix/store/z584w3rd81mfigbr8m3v06kyv21dh7wm-home-manager-path/share/fonts/truetype/NerdFonts/FiraCodeNerdFont-Retina.ttf)
polybar|notice:  Loaded font "Font Awesome 5 Free Regular:style=Solid:size=12" (name=DejaVu Sans, offset=0, file=/nix/store/7370cbzds0g83pn2v298ksq39xprnrhj-dejavu-fonts-2.37/share/fonts/truetype/DejaVuSans.ttf)
polybar|warn:  Ignoring unsupported wm-restack option 'i3'

fish: Process 31614, './result/bin/polybar' from job 3, './result/bin/polybar'
terminated by signal SIGSEGV (Address boundary error)

Expected behavior

  • Print an error when using a field that is not defined
  • Use a default format (doesn't seem to be possible when reading the code)

Actual behavior

Segfaults when calling m_discharging_animation->get() inside battery_module::build

Window Manager and Version

i3 version 4.22 (2023-01-02)

Linux Distribution

NixOs 23.11.20231101.d64dbf7 (Tapir)

Polybar version

polybar 3.6.3

Features: +alsa -curl -i3 -mpd +network(libnl) -pulseaudio +xkeyboard

X extensions: +randr (+monitors) +composite +xkb +xrm +xcursor

Build type: Release
Compiler: /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-gcc-wrapper-12.3.0/bin/g++
Compiler flags:  -O3 -DNDEBUG -Wall -Wextra -Wpedantic -Wsuggest-override
Linker flags:  -Wall -Wextra -Wpedantic -Wsuggest-override  -Wall -Wextra -Wpedantic -Wsuggest-override

Additional Context / Screenshots

No response

patrick96 added a commit to patrick96/polybar that referenced this issue Nov 16, 2023
The 'value' variable that was used for validation, was empty because it
was used in a move at the beginning of the function.

Fixes polybar#3043
@patrick96
Copy link
Member

Huh, turns out our validation code that you don't use invalid tags in formats just doesn't work.

The module shouldn't even start because you can't use <animation-discharge> in format-low.

I have fixed this in #3045 and it should be in the 3.7.1 release soon

patrick96 added a commit that referenced this issue Nov 16, 2023
The 'value' variable that was used for validation, was empty because it
was used in a move at the beginning of the function.

Fixes #3043
@d4ilyrun
Copy link
Author

Nice ! Thanks a lot 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants