flomesh-io / pipy

Pipy is a programmable proxy for the cloud, edge and IoT.
https://flomesh.io/pipy
Other
743 stars 70 forks source link

pipy crash when repo addr point to domain name which is configured in /etc/hosts #118

Closed ethinx closed 1 year ago

ethinx commented 1 year ago

What happened

As subject

Reproduce the issue

  1. Download the latest version(x86) from https://flomesh.io/nightly/
  2. Start a pipy repo
2022-09-20 18:27:06.088 [INF] [admin] Starting admin service...
2022-09-20 18:27:06.088 [INF] [listener] Listening on TCP port 6060 at ::

=============================================

  You can now view Pipy GUI in the browser:

    http://localhost:6060/

=============================================
  1. Set a host entry in /etc/hosts, e.g. 192.168.66.1 pipy-repo.com on the worker node
  2. Start pipy and point to the repo, use domain name instread of IP addr.
pipy http://pipy-repo.com:6060/repo/tutorial/01-hello/

That's all. However if we compile pipy locally and run it on the same node, there is no problem.

May the issue relate to the compiled environment? Only x86 version meets this problem now.

I tried to get the backtrace via gdb as follows

``` Reading symbols from pipy... (gdb) set args http://pipy-repo.com:6060/repo/tutorial/01-hello/ (gdb) start Temporary breakpoint 1 at 0x5b5bf0 Starting program: /usr/local/bin/pipy http://pipy-repo.com:6060/repo/tutorial/01-hello/ Temporary breakpoint 1, 0x00000000005b5bf0 in main () (gdb) s Single stepping until exit from function main, which has no line number information. [New LWP 57759] [New LWP 57760] [New LWP 57761] [New LWP 57762] [New LWP 57763] warning: File "/usr/lib/x86_64-linux-gnu/libthread_db.so.1" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load". To enable execution of this file add add-auto-load-safe-path /usr/lib/x86_64-linux-gnu/libthread_db.so.1 line to your configuration file "/home/ubuntu/.config/gdb/gdbinit". To completely disable this security protection add set auto-load safe-path / line to your configuration file "/home/ubuntu/.config/gdb/gdbinit". For more information about this security protection see the "Auto-loading safe path" section in the GDB manual. E.g., run from the shell: info "(gdb)Auto-loading safe path" warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. Thread 6 "pipy" received signal SIGSEGV, Segmentation fault. [Switching to LWP 57763] 0x00007ffff5650a7f in __GI___pthread_enable_asynccancel () at ./nptl/cancellation.c:34 34 ./nptl/cancellation.c: No such file or directory. (gdb) bt #0 0x00007ffff5650a7f in __GI___pthread_enable_asynccancel () at ./nptl/cancellation.c:34 #1 0x00007ffff5606ca7 in __GI___getrandom (flags=1, length=8, buffer=0x7ffff57e04d8 ) at ../sysdeps/unix/sysv/linux/getrandom.c:29 #2 __GI___getrandom (buffer=buffer@entry=0x7ffff57e04d8 , length=length@entry=8, flags=flags@entry=1) at ../sysdeps/unix/sysv/linux/getrandom.c:27 #3 0x00007ffff5661a66 in tcache_key_initialize () at ./malloc/malloc.c:3162 #4 ptmalloc_init () at ./malloc/arena.c:321 #5 0x00007ffff5665355 in ptmalloc_init () at ./malloc/arena.c:315 #6 __GI___libc_malloc (bytes=472) at ./malloc/malloc.c:3295 #7 0x00007ffff563f6ce in __fopen_internal (is32=1, mode=0x7ffff5798074 "rce", filename=0x7ffff579c262 "/etc/hosts") at ./libio/iofopen.c:65 #8 _IO_new_fopen (filename=0x7ffff579c262 "/etc/hosts", mode=0x7ffff5798074 "rce") at ./libio/iofopen.c:86 #9 0x00007ffff5714e32 in __GI___nss_files_fopen (path=path@entry=0x7ffff579c262 "/etc/hosts") at ./nss/nss_files_fopen.c:27 #10 0x00007ffff5719746 in internal_setent (stream=) at nss_files/files-XXX.c:76 #11 __GI__nss_files_gethostbyname4_r (name=0x7ffff5ff3a80 "pipy-repo.com", pat=0x7ffff5ff3278, buffer=0x7ffff5ff3580 "", buflen=1024, errnop=0x7ffff5ff46b0, herrnop=0x7ffff5ff46e8, ttlp=0x0) at nss_files/files-hosts.c:389 #12 0x0000000000a1688f in gaih_inet.constprop () #13 0x0000000000a183d9 in getaddrinfo () #14 0x00000000005c9431 in asio::detail::resolve_query_op::do_complete(void*, asio::detail::scheduler_operation*, std::error_code const&, unsigned long) () #15 0x0000000000535d81 in asio::detail::scheduler::do_run_one(asio::detail::conditionally_enabled_mutex::scoped_lock&, asio::detail::scheduler_thread_info&, std::error_code const&) () #16 0x00000000005357e1 in asio::detail::scheduler::run(std::error_code&) () #17 0x00000000005c84c6 in asio::detail::posix_thread::func::run() () #18 0x000000000053565d in asio_detail_posix_thread_function () #19 0x00000000008c00f9 in start_thread (arg=) at pthread_create.c:477 #20 0x0000000000a1dd53 in clone () (gdb) ```

Expect behavior

pipy start normally with any valid url.

Version info

OS

Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:        22.04
Codename:       jammy

pipy

Version     : nightly-202209191340
Commit      : 15bd2ef63098d73bcca2dccf4ff8a294ba19dd39
Commit Date : Mon, 19 Sep 2022 21:40:15 +0800
Host        : Linux-5.15.0-1019-azure x86_64
OpenSSL     : OpenSSL 1.1.1q  5 Jul 2022
Builtin GUI : No
Samples     : No
naqvis commented 1 year ago

Sounds like a cross compilation issue. I've tried to reproduce this on Debian 11 (bullseye) , Ubuntu 20.04 (focal) , and Fedora 36 (Workstation) with no luck.

Tested artefact

Can you please help to verify if you are experiencing this problem on Ubuntu 22.04 (jammy) only?

ethinx commented 1 year ago

This might be solved by #150 , will reopen if problem reproduced.