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

Add interface information #3143

Merged
merged 8 commits into from
Sep 25, 2024
Merged

Add interface information #3143

merged 8 commits into from
Sep 25, 2024

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Sep 18, 2024

What does this implement/fix?

This PR implements a Discourse feature request. The particular implementation is up for discussion and possible further improvements therewhile.

Needs pi-hole/FTL#2009 (branch tweak/api_network_info) to work.


Related issue or feature (if applicable): https://discourse.pi-hole.net/t/list-ip-v4-and-v6-address-in-web-interface/70981/11 and also #3076

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

@yubiuser
Copy link
Member

possible further improvements therewhile

I still think the

But the appearance is broken for midnight and high contrast dark theme. For deep-midnight the hover effect is to bright.

@yubiuser
Copy link
Member

The combination of those branches makes the web interface non responding and triggers a constant FTL restart.

nanopi@nanopi:~$ pihole -v
Core
    Version is v5.18.3-479-g111dfc6 (Latest: null)
    Branch is new/optimize
    Hash is 111dfc63 (Latest: 0f4ad773)
Web
    Version is v5.19-853-gac341cf9 (Latest: null)
    Branch is new/ifaces
    Hash is ac341cf9 (Latest: ac341cf9)
FTL
    Version is vDev-4048081 (Latest: null)
    Branch is tweak/db_counter_update
    Hash is 40480814 (Latest: 40480814)
024-09-19 21:37:14.015 CEST [129739/T129741] DEBUG_LOCKS: Waiting for SHM lock in DB_thread() (/app/src/database/database-thread.c:117)
2024-09-19 21:37:14.016 CEST [129739/T129741] DEBUG_LOCKS: SHM lock: 0xffffb6ae0000
2024-09-19 21:37:14.016 CEST [129739/T129741] DEBUG_LOCKS: Obtained SHM lock for DB_thread() (/app/src/database/database-thread.c:117)
2024-09-19 21:37:14.016 CEST [129739/T129741] DEBUG_DATABASE: Accessing in-memory database
2024-09-19 21:37:14.016 CEST [129739/T129741] DEBUG_LOCKS: Removed SHM lock in DB_thread() (/app/src/database/database-thread.c:119)
2024-09-19 21:37:15.021 CEST [129739/T129741] DEBUG_LOCKS: Waiting for SHM lock in DB_thread() (/app/src/database/database-thread.c:117)
2024-09-19 21:37:15.022 CEST [129739/T129741] DEBUG_LOCKS: SHM lock: 0xffffb6ae0000
2024-09-19 21:37:15.022 CEST [129739/T129741] DEBUG_LOCKS: Obtained SHM lock for DB_thread() (/app/src/database/database-thread.c:117)
2024-09-19 21:37:15.022 CEST [129739/T129741] DEBUG_DATABASE: Accessing in-memory database
2024-09-19 21:37:15.024 CEST [129739/T129741] DEBUG_LOCKS: Removed SHM lock in DB_thread() (/app/src/database/database-thread.c:119)
2024-09-19 21:37:15.070 CEST [129739/T129756] DEBUG_API: API Authentication: FAIL (no SID provided)
2024-09-19 21:37:15.070 CEST [129739/T129756] DEBUG_API: Rewriting filename: /var/www/html/admin/login
2024-09-19 21:37:15.071 CEST [129739/T129756] DEBUG_API: Rewriting Lua page: /var/www/html/admin/login ==> /var/www/html/admin/login.lp
2024-09-19 21:37:20.778 CEST [129778M] INFO: ########## FTL started on nanopi! ##########
2024-09-19 21:37:20.779 CEST [129778M] INFO: FTL branch: tweak/db_counter_update
2024-09-19 21:37:20.779 CEST [129778M] INFO: FTL version: vDev-4048081
2024-09-19 21:37:20.779 CEST [129778M] INFO: FTL commit: 40480814
2024-09-19 21:37:20.779 CEST [129778M] INFO: FTL date: 2024-09-18 15:47:15 +0200
2024-09-19 21:37:20.780 CEST [129778M] INFO: FTL user: pihole
2024-09-19 21:37:20.780 CEST [129778M] INFO: Compiled for linux/arm64/v8 (compiled on CI) using cc (Alpine 13.2.1_git20240309) 13.2.1 20240309
2024-09-19 21:37:20.789 CEST [129778M] DEBUG_CONFIG: Reading default TOML config file
2024-09-19 21:37:20.790 CEST [129778M] DEBUG_CONFIG: dns.revServer does not exist - nothing to migrate

@DL6ER
Copy link
Member Author

DL6ER commented Sep 19, 2024

What did you try exactly? I'm on the same combination of the three branches, yet, I can see no delay/unexpected starting at all.

If you can reproduce it reliably, it'd be interesting to see what an attached gdb says:

sudo gdb -p $(cat /var/run/pihole-FTL.pid)

Even when this is not a crash, systemd may be restarting FTL for other reasons. also of interest would be the output of:

sudo journalctl -u pihole-FTL.service

@yubiuser
Copy link
Member

What did you try exactly?

Only accessing the web interface (login page). It is reproducible.

--Type <RET> for more, q to quit, c to continue without paging--c
[New LWP 135948]
[New LWP 135949]
__syscall_cp_asm () at src/thread/aarch64/syscall_cp.s:28
28	src/thread/aarch64/syscall_cp.s: Datei oder Verzeichnis nicht gefunden.
(gdb) c
Continuing.
[New LWP 135952]

Thread 11 "civetweb-worker" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 135952]
vfprintf (f=f@entry=0xffff97557138, fmt=0x7dc348 "%lld", ap=...)
    at src/stdio/vfprintf.c:667
667	src/stdio/vfprintf.c: Datei oder Verzeichnis nicht gefunden.
(gdb) c
Continuing.

Thread 11 "civetweb-worker" received signal SIGSEGV, Segmentation fault.
vfprintf (f=f@entry=0xffff97557138, fmt=0x7dc348 "%lld", ap=...)
    at src/stdio/vfprintf.c:667
667	in src/stdio/vfprintf.c
(gdb) backtrace
#0  vfprintf (f=f@entry=0xffff97557138, fmt=0x7dc348 "%lld", ap=...)
    at src/stdio/vfprintf.c:667
#1  0x000000000079a7bc in vsnprintf (s=<optimized out>, n=<optimized out>, 
    fmt=<optimized out>, ap=...) at src/stdio/vsnprintf.c:49
#2  0x000000000079734c in snprintf (s=<optimized out>, n=<optimized out>, 
    fmt=<optimized out>) at src/stdio/snprintf.c:9
#3  0x000000000064bf34 in addnum2buff (num=<optimized out>, 
    buff=<optimized out>) at /app/src/lua/lobject.c:471
#4  luaO_pushvfstring (L=L@entry=0xffff99e2b998, fmt=<optimized out>, 
    fmt@entry=0x7efc48 "%s:%d: %s", argp=...) at /app/src/lua/lobject.c:514
#5  0x000000000064cac0 in luaO_pushfstring (L=L@entry=0xffff99e2b998, 
    fmt=fmt@entry=0x7efc48 "%s:%d: %s") at /app/src/lua/lobject.c:553
#6  0x000000000063ab98 in luaG_addinfo (L=L@entry=0xffff99e2b998, 
    msg=0xffff99c93a68 "attempt to call a string value (field 'rev_proxy')", 
    src=<optimized out>, line=45) at /app/src/lua/ldebug.c:822
#7  0x000000000063af1c in luaG_runerror (L=L@entry=0xffff99e2b998, 
    fmt=fmt@entry=0x7efc58 "attempt to %s a %s value%s")
    at /app/src/lua/ldebug.c:89
#8  0x000000000063b278 in typeerror (
    extra=0xffff99c9e948 " (field 'rev_proxy')", op=0x7bf3d8 "call", 
    o=0xffff99c1e750, L=0xffff99e2b998) at /app/src/lua/ldebug.c:745
#9  luaG_callerror (L=L@entry=0xffff99e2b998, o=o@entry=0xffff99c1e750)
    at /app/src/lua/ldebug.c:768
--Type <RET> for more, q to quit, c to continue without paging--c
#10 0x000000000063c354 in tryfuncTM (L=L@entry=0xffff99e2b998, func=func@entry=0xffff99c1e750)
    at /app/src/lua/ldo.c:418
#11 0x000000000063df94 in luaD_precall (nresults=<optimized out>, func=0xffff99c1e750, 
    L=<optimized out>) at /app/src/lua/ldo.c:612
#12 ccall (inc=65537, nResults=1, func=<optimized out>, L=0xffff99e2b998) at /app/src/lua/ldo.c:635
#13 luaD_callnoyield (L=L@entry=0xffff99e2b998, func=<optimized out>, nResults=nResults@entry=1)
    at /app/src/lua/ldo.c:655
#14 0x000000000063ac48 in luaG_errormsg (L=L@entry=0xffff99e2b998) at /app/src/lua/ldebug.c:833
#15 0x000000000063ad28 in luaG_runerror (L=L@entry=0xffff99e2b998, 
    fmt=fmt@entry=0x7efc58 "attempt to %s a %s value%s") at /app/src/lua/ldebug.c:852
#16 0x000000000063b278 in typeerror (extra=0xffff99c9e948 " (field 'rev_proxy')", op=0x7bf3d8 "call", 
    o=0xffff99c1e720, L=0xffff99e2b998) at /app/src/lua/ldebug.c:745
#17 luaG_callerror (L=L@entry=0xffff99e2b998, o=o@entry=0xffff99c1e720) at /app/src/lua/ldebug.c:768
#18 0x000000000063c354 in tryfuncTM (L=L@entry=0xffff99e2b998, func=func@entry=0xffff99c1e720)
    at /app/src/lua/ldo.c:418
#19 0x000000000063df94 in luaD_precall (nresults=<optimized out>, func=0xffff99c1e720, 
    L=<optimized out>) at /app/src/lua/ldo.c:612
#20 ccall (inc=65537, nResults=1, func=<optimized out>, L=0xffff99e2b998) at /app/src/lua/ldo.c:635
#21 luaD_callnoyield (L=L@entry=0xffff99e2b998, func=<optimized out>, nResults=nResults@entry=1)
    at /app/src/lua/ldo.c:655
#22 0x000000000063ac48 in luaG_errormsg (L=L@entry=0xffff99e2b998) at /app/src/lua/ldebug.c:833
#23 0x000000000063ad28 in luaG_runerror (L=L@entry=0xffff99e2b998, 
.....
many many lines
.....
    u=u@entry=0xffff97572498, old_top=32, ef=<optimized out>) at /app/src/lua/ldo.c:957
#1649 0x000000000062bbd0 in lua_pcallk (L=L@entry=0xffff99e2b998, nargs=nargs@entry=0, 
    nresults=nresults@entry=0, errfunc=errfunc@entry=1, ctx=ctx@entry=0, k=k@entry=0x0)
    at /app/src/lua/lapi.c:1064
#1650 0x00000000004564d4 in run_lsp_kepler (depth=1, L=0xffff99e2b998, len=7961, 
    p=0xffff99c95000 "<? --[[\n*  Pi-hole: A black hole for Internet advertisements\n*  (c) 2017 Pi-hole, LLC (https://pi-hole.net)\n*  Network-wide ad blocking via your own hardware.\n*\n*  This file is copyright under the lat"..., path=<optimized out>, conn=0xffff99edab90)
    at /app/src/webserver/civetweb/mod_lua.inl:677
#1651 handle_lsp_request (conn=0xffff99edab90, path=<optimized out>, filep=0xffff975726a8, ls=0x0)
    at /app/src/webserver/civetweb/mod_lua.inl:3244
#1652 0x000000000045c60c in handle_request (conn=conn@entry=0xffff99edab90)
    at /app/src/webserver/civetweb/civetweb.c:15605
#1653 0x000000000045d504 in handle_request_stat_log (conn=0xffff99edab90)
    at /app/src/webserver/civetweb/civetweb.c:6737
#1654 process_new_connection (conn=conn@entry=0xffff99edab90)
    at /app/src/webserver/civetweb/civetweb.c:19844
#1655 0x000000000045e87c in worker_thread_run (conn=0xffff99edab90)
    at /app/src/webserver/civetweb/civetweb.c:20216
#1656 worker_thread (thread_func_param=0xffff99edab90) at /app/src/webserver/civetweb/civetweb.c:20345
#1657 0x000000000079d69c in start (p=0xffff97577b00) at src/thread/pthread_create.c:207
#1658 0x00000000007a759c in __clone () at src/thread/aarch64/clone.s:28
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Sep 19 21:29:51 nanopi pihole-FTL[128868]: 2024-09-19 21:29:51.310 CEST [128868M] INFO: Parsed config file /etc/pihole/pihole.toml succe>
Sep 19 21:29:53 nanopi pihole-FTL[128868]: 2024-09-19 21:29:51.334 CEST [128868M] INFO: PID of FTL process: 128868
Sep 19 21:29:55 nanopi systemd[1]: pihole-FTL.service: Main process exited, code=killed, status=11/SEGV
Sep 19 21:29:56 nanopi systemd[1]: pihole-FTL.service: Failed with result 'signal'.
Sep 19 21:29:56 nanopi systemd[1]: pihole-FTL.service: Consumed 2.819s CPU time.

@DL6ER
Copy link
Member Author

DL6ER commented Sep 20, 2024

Thanks for the backtrace, this is already very helpful. We're faced with a bug in the LUA library itself. More precisely, an infinite loop when it tries to log

%s:%d: attempt to call a string value (field 'rev_proxy')

The first two placeholders should be replaced by the file and line and this is where it gets interesting. They want to print %d but the code actually tries to print %lld. Depending on which machine you are testing (I am testing on x86_64), this may really be the cause as long long int is at least 64 bits long but your int may be only 16 bits long. On my machine, it is already 32 bits which may simply prevent this issue from happening.

I'm afraid I'd need two things from you:

  1. Assuming you have all debug flags flipped on (including debug.webserver), I'd be interested in the last lines of /var/log/pihole/webserver.log
  2. I need some more of the "many many lines" stuff

My hope is still to find that this bug is actually caused by CivetWeb and fixable without having to deal with the LUA code itself. Chances are low but anyway.

@DL6ER
Copy link
Member Author

DL6ER commented Sep 20, 2024

@yubiuser I did just push a commit that adds additional debugging output to webserver.log when trying to log an error. Trying to narrow down on the CIvetWeb or LUA bug.

Memo for myself: What I am concerned about here is that

  • the format string is %s:%d
  • lua_debug has line as int
  • the backtrace above shows that luaO_pushvfstring is going the 514 route (which is actually %f, not %d)
  • the crash then happens inside vfprintf which got %lld (not %d), probably causing the memory error

The two former are fine, the two latter don't make much sense to me right now and are both wrong (in different ways).

Interestingly enough: Why don't I get the error message myself?...

@yubiuser
Copy link
Member

yubiuser commented Sep 20, 2024

Here you go. In the webserver.log two "restarts" are logged. The one on 13:18 is still on the old FTL commit, the later one on the new FTL commit. The gdb output is from the latter

webserver.log
gdb.log


I find it more interestingly that it is caused by a new web branch not the ftl branch. Switching to web development and everything works fine - but nothing has changes on the login page.

@yubiuser
Copy link
Member

Regarding the used architecture

*** [ DIAGNOSING ]: Processor details
[i] lscpu
Architecture:                         aarch64
CPU op-mode(s):                       32-bit, 64-bit
Byte Order:                           Little Endian
CPU(s):                               4
On-line CPU(s) list:                  0-3
Vendor ID:                            ARM
Model name:                           Cortex-A53
Model:                                4
Thread(s) per core:                   1
Core(s) per cluster:                  4
Socket(s):                            -
Cluster(s):                           1
Stepping:                             r0p4
CPU(s) scaling MHz:                   100%
CPU max MHz:                          1368,0000
CPU min MHz:                          480,0000
BogoMIPS:                             48,00
Flags:                                fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid

@DL6ER
Copy link
Member Author

DL6ER commented Sep 20, 2024

I find it more interestingly that it is caused by a new web branch not the ftl branch. Switching to web development and everything works fine - but nothing has changes on the login page.

The bug is that error reporting is not working. Somehow the error doesn't seem to be reported for you on development. But then ... it isn't reported for me on either branch... even though pihole.rev_server() is gone in both branches.

... thinking ...

okay, after staring at the code for some time, I realized that a necessity to trigger the issue is not using HTTPS when accessing the web interface. Without HTTPS, I can - at least - see that the web interface doesn't load properly - even when I can still not reproduce the crash and neither receive the error message itself.

@DL6ER
Copy link
Member Author

DL6ER commented Sep 20, 2024

Another interesting detail I found midway: The hundreds of thousands of iterations you have seen above ("many many lines") cause a stack overflow deep inside LUA code. This also seems to be the reason why I don't see the error message. The errors happens, LUA tried to report it, gets caught in some infinite loop, corrupts its own stack, then somehow leaves the infinite loop and thinks nothing bad has ever happened... Investigation ongoing...

@DL6ER
Copy link
Member Author

DL6ER commented Sep 20, 2024

Update: It turned out to be a hard-to-find but thankfully easy-to-fix bug in Civetweb. See civetweb/civetweb#1296

@yubiuser
Copy link
Member

After the lua fix the web interface loads successfully. So let's get back to this one. It needs a rebase on current development and some CSS polishing
2024-09-24_13-43

…emes

using a semi-tranparent color

Signed-off-by: RD WebDesign <[email protected]>
@rdwebdesign
Copy link
Member

... and some CSS polishing

I added a commit fixing the CSS for all current themes.

Copy link
Member

@yubiuser yubiuser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add bstreeview to the package.json (so dependabot can inform us about an update if it will ever happen)

"dependencies": {

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved.

@DL6ER DL6ER merged commit 8ddcbda into development Sep 25, 2024
12 checks passed
@DL6ER DL6ER deleted the new/ifaces branch September 25, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants