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

Segfaults when context vars are duplicated #121

Closed naqvis closed 1 year ago

naqvis commented 1 year ago

Bug Report

Duplicating context variables is causing Pipy to Segv on *nix based systems. Behavior is inconsistent on different Oses as on CentOS it crashes at startup, while on Ubuntu (focal) 20.04 LTS , it crashes at exit.

Mac M1 machine doesn't show this behavior

Pipy Version

Version     : nightly-202210120857
Commit      : 78b04769a3c9144aa42edb3b893bbce203c32e1f
Commit Date : Wed, 12 Oct 2022 16:57:28 +0800
Host        : Linux-5.15.0-1020-azure x86_64
OpenSSL     : OpenSSL 1.1.1q  5 Jul 2022
Builtin GUI : No

Steps to reproduce

$ pipy -e "pipy({_g: {}, _g: {}}).listen(8000)"

Output

$ ./pipy -e "pipy({_g: {}, _g: ''}).listen(8000)"
2022-10-14 14:13:09.638 [INF] [config]
2022-10-14 14:13:09.638 [INF] [config] Module
2022-10-14 14:13:09.638 [INF] [config] =======
2022-10-14 14:13:09.638 [INF] [config]
2022-10-14 14:13:09.638 [INF] [config]  [Listen on 8000 at 0.0.0.0]
2022-10-14 14:13:09.638 [INF] [config]  ----->|
2022-10-14 14:13:09.638 [INF] [config]        |
2022-10-14 14:13:09.638 [INF] [config]
2022-10-14 14:13:09.638 [INF] [config]  <---|
2022-10-14 14:13:09.638 [INF] [config]
2022-10-14 14:13:09.638 [INF] [listener] Listening on TCP port 8000 at 0.0.0.0
^C2022-10-14 14:13:12.648 [INF] [shutdown] Shutting down...
Segmentation fault (core dumped)
pajama-coder commented 1 year ago

Fixed in commit f812272711be05afac07c10f11e32f640d74e45a

naqvis commented 1 year ago

Thanks @pajama-coder. Verified on Ubuntu and CentOS and fix working as expected. Closing this issue now.