lonkamikaze / powerdxx

powerd++ is a drop in replacement for FreeBSD's powerd
https://lonkamikaze.github.io/powerdxx
ISC License
86 stars 3 forks source link

FreeBSD 13: instant crash if installed from pkg and unable to build in ports #17

Open FrostKiwi opened 3 years ago

FrostKiwi commented 3 years ago

On FreeBSD 13, installing powerdxx works, but running it insta crashes: fish: Job 1, 'sudo powerdxx' terminated by signal SIGSEGV (Address boundary error) Bash simply reports "Segmentation Fault" Building from ports results in: /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/utility.hpp:8:47: fatal error: charconv: No such file or directory Here the full log:

Log from sudo make in /usr/ports/sysutils/powerdxx`===> Building for powerdxx-0.4.4 --- powerd++.o --- --- clas.o --- --- powerd++.o --- c++ -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -std=c++17 -Wall -Werror -pedantic -c /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/powerd++.cpp -o powerd++.o --- clas.o --- c++ -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -std=c++17 -Wall -Werror -pedantic -c /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/clas.cpp -o clas.o --- powerd++.o --- In file included from /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/Options.hpp:130:0, from /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/powerd++.cpp:7: /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/utility.hpp:8:47: fatal error: charconv: No such file or directory #include /* std::from_chars() */ ^ compilation terminated. *** [powerd++.o] Error code 1 make[2]: stopped in /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4 --- clas.o --- In file included from /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/errors.hpp:7:0, from /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/clas.hpp:11, from /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/clas.cpp:7: /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4/src/utility.hpp:8:47: fatal error: charconv: No such file or directory #include /* std::from_chars() */ ^ compilation terminated. *** [clas.o] Error code 1 make[2]: stopped in /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4 2 errors make[2]: stopped in /usr/ports/sysutils/powerdxx/work/powerdxx-0.4.4 ===> Compilation failed unexpectedly. Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to the maintainer. *** Error code 1 Stop. make[1]: stopped in /usr/ports/sysutils/powerdxx *** Error code 1 Stop. make: stopped in /usr/ports/sysutils/powerdxx`
lonkamikaze commented 3 years ago

The <charconv> header should be located under /usr/include/c++/v1/charconv. Can you verify that?

I would of course like a backtrace of the crash if you're willing to make a debug build and run it, but that requires you to be able to build it. Did you perfrom a custom WITHOUT_TOOLCHAIN install of FreeBSD?

FrostKiwi commented 3 years ago

The <charconv> header should be located under /usr/include/c++/v1/charconv. Can you verify that?

I would of course like a backtrace of the crash if you're willing to make a debug build and run it, but that requires you to be able to build it. Did you perfrom a custom WITHOUT_TOOLCHAIN install of FreeBSD?

charconv.txt No WITHOUT_TOOLCHAIN things have been done. That one's new to me. Yes it's there. Curiously though, it lacks a file extension, though maybe that's normal. Here is ls -lh /usr/include/c++/v1/

ls -lh > total 4636 > -r--r--r-- 1 root wheel 52K Apr 9 08:12 __bit_reference > -r--r--r-- 1 root wheel 2.1K Apr 9 08:12 __bsd_locale_defaults.h > -r--r--r-- 1 root wheel 3.9K Apr 9 08:12 __bsd_locale_fallbacks.h > -r--r--r-- 1 root wheel 52K Apr 9 08:12 __config > -r--r--r-- 1 root wheel 7.8K Apr 9 08:12 __debug > -r--r--r-- 1 root wheel 9.1K Apr 9 08:12 __errc > -r--r--r-- 1 root wheel 44K Apr 9 08:12 __functional_03 > -r--r--r-- 1 root wheel 17K Apr 9 08:12 __functional_base > -r--r--r-- 1 root wheel 6.4K Apr 9 08:12 __functional_base_03 > -r--r--r-- 1 root wheel 102K Apr 9 08:12 __hash_table > -r--r--r-- 1 root wheel 6B Apr 9 08:12 __libcpp_version > -r--r--r-- 1 root wheel 48K Apr 9 08:12 __locale > -r--r--r-- 1 root wheel 16K Apr 9 08:12 __mutex_base > -r--r--r-- 1 root wheel 5.9K Apr 9 08:12 __node_handle > -r--r--r-- 1 root wheel 1.7K Apr 9 08:12 __nullptr > -r--r--r-- 1 root wheel 22K Apr 9 08:12 __split_buffer > -r--r--r-- 1 root wheel 2.5K Apr 9 08:12 __sso_allocator > -r--r--r-- 1 root wheel 10K Apr 9 08:12 __std_stream > -r--r--r-- 1 root wheel 46K Apr 9 08:12 __string > -r--r--r-- 1 root wheel 21K Apr 9 08:12 __threading_support > -r--r--r-- 1 root wheel 102K Apr 9 08:12 __tree > -r--r--r-- 1 root wheel 20K Apr 9 08:12 __tuple > -r--r--r-- 1 root wheel 1.0K Apr 9 08:12 __undef_macros > -r--r--r-- 1 root wheel 199K Apr 9 08:12 algorithm > -r--r--r-- 1 root wheel 19K Apr 9 08:12 any > -r--r--r-- 1 root wheel 20K Apr 9 08:12 array > -r--r--r-- 1 root wheel 97K Apr 9 08:12 atomic > -r--r--r-- 1 root wheel 14K Apr 9 08:12 bit > -r--r--r-- 1 root wheel 33K Apr 9 08:12 bitset > -r--r--r-- 1 root wheel 559B Apr 9 08:12 cassert > -r--r--r-- 1 root wheel 640B Apr 9 08:12 ccomplex > -r--r--r-- 1 root wheel 1.7K Apr 9 08:12 cctype > -r--r--r-- 1 root wheel 669B Apr 9 08:12 cerrno > -r--r--r-- 1 root wheel 1.6K Apr 9 08:12 cfenv > -r--r--r-- 1 root wheel 1.4K Apr 9 08:12 cfloat > -r--r--r-- 1 root wheel 18K Apr 9 08:12 charconv > -r--r--r-- 1 root wheel 114K Apr 9 08:12 chrono > -r--r--r-- 1 root wheel 3.4K Apr 9 08:12 cinttypes > -r--r--r-- 1 root wheel 595B Apr 9 08:12 ciso646 > -r--r--r-- 1 root wheel 907B Apr 9 08:12 climits > -r--r--r-- 1 root wheel 998B Apr 9 08:12 clocale > -r--r--r-- 1 root wheel 17K Apr 9 08:12 cmath > -r--r--r-- 1 root wheel 20K Apr 9 08:12 codecvt > -r--r--r-- 1 root wheel 30K Apr 9 08:12 compare > -r--r--r-- 1 root wheel 46K Apr 9 08:12 complex > -r--r--r-- 1 root wheel 739B Apr 9 08:12 complex.h > -r--r--r-- 1 root wheel 7.4K Apr 9 08:12 condition_variable > -r--r--r-- 1 root wheel 813B Apr 9 08:12 csetjmp > -r--r--r-- 1 root wheel 964B Apr 9 08:12 csignal > -r--r--r-- 1 root wheel 903B Apr 9 08:12 cstdarg > -r--r--r-- 1 root wheel 721B Apr 9 08:12 cstdbool > -r--r--r-- 1 root wheel 5.3K Apr 9 08:12 cstddef > -r--r--r-- 1 root wheel 2.7K Apr 9 08:12 cstdint > -r--r--r-- 1 root wheel 4.3K Apr 9 08:12 cstdio > -r--r--r-- 1 root wheel 4.7K Apr 9 08:12 cstdlib > -r--r--r-- 1 root wheel 2.5K Apr 9 08:12 cstring > -r--r--r-- 1 root wheel 650B Apr 9 08:12 ctgmath > -r--r--r-- 1 root wheel 1.7K Apr 9 08:12 ctime > -r--r--r-- 1 root wheel 1.1K Apr 9 08:12 ctype.h > -r--r--r-- 1 root wheel 6.1K Apr 9 08:12 cwchar > -r--r--r-- 1 root wheel 1.7K Apr 9 08:12 cwctype > -r--r--r-- 1 root wheel 8.6K Apr 9 08:12 cxxabi.h > -r--r--r-- 1 root wheel 106K Apr 9 08:12 deque > -r--r--r-- 1 root wheel 6.2K Apr 9 08:12 errno.h > -r--r--r-- 1 root wheel 9.2K Apr 9 08:12 exception > drwxr-xr-x 2 root wheel 512B Apr 9 08:12 experimental > drwxr-xr-x 2 root wheel 512B Apr 9 08:12 ext > -r--r--r-- 1 root wheel 1.8K Apr 9 08:12 fenv.h > -r--r--r-- 1 root wheel 80K Apr 9 08:12 filesystem > -r--r--r-- 1 root wheel 1.6K Apr 9 08:12 float.h > -r--r--r-- 1 root wheel 61K Apr 9 08:12 forward_list > -r--r--r-- 1 root wheel 53K Apr 9 08:12 fstream > -r--r--r-- 1 root wheel 100K Apr 9 08:12 functional > -r--r--r-- 1 root wheel 71K Apr 9 08:12 future > -r--r--r-- 1 root wheel 2.8K Apr 9 08:12 initializer_list > -r--r--r-- 1 root wheel 3.8K Apr 9 08:12 inttypes.h > -r--r--r-- 1 root wheel 18K Apr 9 08:12 iomanip > -r--r--r-- 1 root wheel 25K Apr 9 08:12 ios > -r--r--r-- 1 root wheel 8.3K Apr 9 08:12 iosfwd > -r--r--r-- 1 root wheel 1.4K Apr 9 08:12 iostream > -r--r--r-- 1 root wheel 47K Apr 9 08:12 istream > -r--r--r-- 1 root wheel 70K Apr 9 08:12 iterator > -r--r--r-- 1 root wheel 40K Apr 9 08:12 limits > -r--r--r-- 1 root wheel 1.4K Apr 9 08:12 limits.h > -r--r--r-- 1 root wheel 78K Apr 9 08:12 list > -r--r--r-- 1 root wheel 151K Apr 9 08:12 locale > -r--r--r-- 1 root wheel 776B Apr 9 08:12 locale.h > -r--r--r-- 1 root wheel 83K Apr 9 08:12 map > -r--r--r-- 1 root wheel 48K Apr 9 08:12 math.h > -r--r--r-- 1 root wheel 161K Apr 9 08:12 memory > -r--r--r-- 1 root wheel 17K Apr 9 08:12 mutex > -r--r--r-- 1 root wheel 14K Apr 9 08:12 new > -r--r--r-- 1 root wheel 20K Apr 9 08:12 numeric > -r--r--r-- 1 root wheel 42K Apr 9 08:12 optional > -r--r--r-- 1 root wheel 32K Apr 9 08:12 ostream > -r--r--r-- 1 root wheel 27K Apr 9 08:12 queue > -r--r--r-- 1 root wheel 221K Apr 9 08:12 random > -r--r--r-- 1 root wheel 16K Apr 9 08:12 ratio > -r--r--r-- 1 root wheel 220K Apr 9 08:12 regex > -r--r--r-- 1 root wheel 25K Apr 9 08:12 scoped_allocator > -r--r--r-- 1 root wheel 56K Apr 9 08:12 set > -r--r--r-- 1 root wheel 802B Apr 9 08:12 setjmp.h > -r--r--r-- 1 root wheel 15K Apr 9 08:12 shared_mutex > -r--r--r-- 1 root wheel 22K Apr 9 08:12 span > -r--r--r-- 1 root wheel 33K Apr 9 08:12 sstream > -r--r--r-- 1 root wheel 9.9K Apr 9 08:12 stack > -r--r--r-- 1 root wheel 815B Apr 9 08:12 stdbool.h > -r--r--r-- 1 root wheel 1.1K Apr 9 08:12 stddef.h > -r--r--r-- 1 root wheel 7.7K Apr 9 08:12 stdexcept > -r--r--r-- 1 root wheel 2.3K Apr 9 08:12 stdint.h > -r--r--r-- 1 root wheel 3.4K Apr 9 08:12 stdio.h > -r--r--r-- 1 root wheel 5.1K Apr 9 08:12 stdlib.h > -r--r--r-- 1 root wheel 14K Apr 9 08:12 streambuf > -r--r--r-- 1 root wheel 163K Apr 9 08:12 string > -r--r--r-- 1 root wheel 4.6K Apr 9 08:12 string.h > -r--r--r-- 1 root wheel 34K Apr 9 08:12 string_view > -r--r--r-- 1 root wheel 11K Apr 9 08:12 strstream > -r--r--r-- 1 root wheel 14K Apr 9 08:12 system_error > -r--r--r-- 1 root wheel 732B Apr 9 08:12 tgmath.h > -r--r--r-- 1 root wheel 11K Apr 9 08:12 thread > drwxr-xr-x 2 root wheel 2.5K Apr 9 08:12 tr1 > -r--r--r-- 1 root wheel 55K Apr 9 08:12 tuple > -r--r--r-- 1 root wheel 148K Apr 9 08:12 type_traits > -r--r--r-- 1 root wheel 2.8K Apr 9 08:12 typeindex > -r--r--r-- 1 root wheel 11K Apr 9 08:12 typeinfo > -r--r--r-- 1 root wheel 97K Apr 9 08:12 unordered_map > -r--r--r-- 1 root wheel 68K Apr 9 08:12 unordered_set > -r--r--r-- 1 root wheel 7.4K Apr 9 08:12 unwind-arm.h > -r--r--r-- 1 root wheel 6.3K Apr 9 08:12 unwind-itanium.h > -r--r--r-- 1 root wheel 1.4K Apr 9 08:12 unwind.h > -r--r--r-- 1 root wheel 48K Apr 9 08:12 utility > -r--r--r-- 1 root wheel 132K Apr 9 08:12 valarray > -r--r--r-- 1 root wheel 61K Apr 9 08:12 variant > -r--r--r-- 1 root wheel 109K Apr 9 08:12 vector > -r--r--r-- 1 root wheel 15K Apr 9 08:12 version > -r--r--r-- 1 root wheel 8.2K Apr 9 08:12 wchar.h > -r--r--r-- 1 root wheel 1.5K Apr 9 08:12 wctype.h
lonkamikaze commented 3 years ago

Can you go to the ports directory and run the following commands:

FrostKiwi commented 3 years ago

Can you go to the ports directory and run the following commands:

* `make -VMAKE_ENV -VMAKE_ARGS`

* `printenv`

* `which c++`

Ohh dear, that one really was on me. To compile coreboot I needed to specify gcc6-aux in my path to get the ADA compiler gnat to work. That messed with ports.

powerdxx successfully compiles, but as before SEGFAULTS instantly upon launch.

lonkamikaze commented 3 years ago

Can you try to build the port with make -DWITH_DEBUG and produce a backtrace of the crash?

FrostKiwi commented 3 years ago

Can you try to build the port with make -DWITH_DEBUG and produce a backtrace of the crash?

Here it is powerd++.core.tar.gz

FrostKiwi commented 3 years ago

Just for reference, with a freshly built FreeBSD 13 Kernel and a freshly FreeBSD1 3 world, the segfault still happens and makes powerdxx unusable.

FrostKiwi commented 3 years ago

@lonkamikaze Tested again today on 2 different machines. Powerdxx works for this machine:

Specs: Machine it works for ``` System: Host: flandre Kernel: FreeBSD 12.2-RELEASE-p1 amd64 bits: 64 compiler: clang v: 10.0.1 Console: tty pts/0 OS: FreeBSD 12.2-RELEASE-p1 CPU: Info: 16-Core model: AMD Opteron 6284 SE bits: 64 type: MCP arch: Bulldozer rev: 2 cache: L2: N/A features: avx lm nx pae sse sse2 sse3 sse4a ssse3 svm Speed: 2700 MHz min/max: N/A Core speed (MHz): N/A Graphics: Device-1: ASPEED Graphics Family driver: vgapci bus-ID: 0:8:1.0 chip-ID: 1a03:2000 Display: server: No display server data found. Headless machine? tty: 160x47 Message: Advanced graphics data unavailable in console. Try -G --display ```
Specs: But it does not work for this Thinkpad x200. ``` System: Host: stripes Kernel: FreeBSD 13.0-RELEASE amd64 bits: 64 compiler: clang v: 11.0.1 Desktop: sway 1.6-d7a5637f dm: N/A OS: FreeBSD 13.0-RELEASE CPU: Info: Dual Core model: Intel Core2 Duo P8800 bits: 64 type: MCP arch: Penryn rev: A cache: L2: N/A features: lm nx pae sse sse2 sse3 ssse3 vmx Speed: 2666 MHz min/max: N/A Core speed (MHz): N/A Graphics: Device-1: Intel Mobile 4 Series Integrated Graphics driver: vgapci bus-ID: 0:0:2.0 chip-ID: 8086:2a42 Display: wayland server: X.Org 1.21.0.99 compositor: sway driver: loaded: intel resolution: 1280x800~60Hz s-dpi: 96 OpenGL: renderer: Mesa Mobile Intel GM45 Express (CTG) v: 2.1 Mesa 21.3.0-devel (git-8bb9e9e76fa) direct render: Yes ```

This marks another GM45 machines, where powerdxx SEGFAULTS. This Github issue was created, because it SEGFAULTED on a Thinkpad T500. So maybe GM45 at fault? The hardware clocks were a mess with GM45 + FreeBSD so maybe that plays a role? Here is the coredump of powerdxx of with the x200 segfault: powerd++.core.gz

lonkamikaze commented 2 years ago

I found a bug with the address sanitiser, I have a vague hope that that might have been the issue: https://github.com/lonkamikaze/powerdxx/commit/28e61dbd3c5ecbb43d161729b5afb18d38f40d76

Are you willing to test this?

FrostKiwi commented 2 years ago

@lonkamikaze Thanks on following up on old issues :] Will test it.

FrostKiwi commented 2 years ago

I found a bug with the address sanitiser, I have a vague hope that that might have been the issue: 28e61db

Are you willing to test this?

Compiled from master and tested. Same deal. Instant Segmentation Fault on GM45 Laptops.

It might be unrelated, but I wanted to mention it anyways again: Manually changing dev.cpu.0.freq works but there was this hardware timer bug thingy, that prevented this CPU from going into deeper C states ( https://forums.freebsd.org/threads/c-states-not-used.66192/page-2#post-514861 / https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256261) unless you change the hardware timer. The same thing was present in DragonFlyBSD. If powerdxx does anything in that regard, querying hardware timer thingies or whatever, this might be related. Though just a shot in the dark from me...

lonkamikaze commented 2 years ago

No, it's not doing anything like that.

To use the core dumps provided I also need the binary that was run, otherwise I cannot create a backtrace.

FrostKiwi commented 2 years ago

No, it's not doing anything like that.

To use the core dumps provided I also need the binary that was run, otherwise I cannot create a backtrace.

powerd++.core.gz powerd++.gz

Attached are both the binary and the coredump

lonkamikaze commented 2 years ago

This is a stripped binary, no debugging symbols, can you test a binary built with make debug paranoid? On my system the resulting binary is 5 MB large.

FrostKiwi commented 2 years ago

This is a stripped binary, no debugging symbols, can you test a binary built with make debug paranoid? On my system the resulting binary is 5 MB large.

When building with "make debug paranoid", the resulting binary is this one: powerd++_paranoid.gz

It immediatly crashes with "Illegal Instruction" and produces no coredump.

When building with just "make debug" the resulting binary is this one: powerd++.gz

It crashes with "Segmentation Fault" and produces the following coredump: powerd++.core.gz

lonkamikaze commented 2 years ago

It's very frustrating. I cannot get a backtrace out of the coredump, there's just a single frame, not being resolved to any function and if I run the binary myself, it doesn't crash. :(

FrostKiwi commented 2 years ago

It's very frustrating. I cannot get a backtrace out of the coredump, there's just a single frame, not being resolved to any function and if I run the binary myself, it doesn't crash. :(

Then let's leave it alone and I will stick to powerd. It's very interesting though, that this affects GM45 specifically on two different laptops. "Illegal Instruction" is very suspicions. Either way, thx for your efforts. I will continue using powerd++, just not on GM45 :]