mdavidsaver / pvxs

PVA protocol client/server library and utilities.
https://mdavidsaver.github.io/pvxs/
Other
19 stars 25 forks source link

TypeDef from Value containing Union does not work #36

Closed KrMeeus closed 1 year ago

KrMeeus commented 1 year ago

Describe the bug Creating TypeDef from Value containing Union does not work. This is clearly a bug that can be reproduced with the test as follows.

To Reproduce The bug can be reproduced with following test:

void testGetTypeDefFromValue()
{
    testDiag("%s()", __func__);

    using namespace pvxs::members;
    auto top = TypeDef(TypeCode::Struct, "top_t", {
                       Struct("scalar", {
                           Int32("i32"),
                           UInt32("u32"),
                           Bool("b"),
                           Float64("f64"),
                           String("s"),
                           Any("wildcard"),
                           Union("choice", {
                               Int32("one"),
                               Struct("two", {
                                   Int32("ahalf"),
                               }),
                           }),
                       }),
                       Struct("array", {
                           Int32A("i32"),
                           StringA("s"),
                           AnyA("wildcard"),
                           UnionA("choice", {
                               Int32("one"),
                               Struct("two", {
                                   Int32("ahalf"),
                               }),
                           }),
                           StructA("more", {
                               Int32("one"),
                               Struct("two", {
                                   Int32("ahalf"),
                               }),
                           }),
                       }),
                   }).create();

    TypeDef(top);    // !! INFINITE RECURSION !! //
}

Expected behavior

TypeDef should return (and shouldn’t go into an infinite recursion).

Information (please complete the following):

PVXS Version or Git commit ID: initially fixed on edbcd46a5f41366e9601eb9832cd61c260ff58e4, merged and retested with 9c546f0ed448ec9f17d9b676119fa98d66217f6a

Host OS: CentOS8.5.2111 (WSL2)

output of pvxinfo -D.

Host: linux-x86_64
Target: linux-x86_64 Linux gcc
Toolchain
    __cplusplus = 201103
    GCC 8.5.0
    _GLIBCXX_USE_CXX11_ABI = 1
    GLIBC 2.28
    __GLIBCXX__ 20210514
Versions
    PVXS 1.1.2 (1.1.2-15-g9c546f0ed448ec9f17d9-dirty)
    EPICS 7.0.6.1-DEV
    libevent 2.1.8-stable
Runtime
    uname() -> Linux PC6107 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64
    epicsThreadGetCPUs() -> 16
    osiLocalAddr() -> 172.27.168.0
    osiSockDiscoverBroadcastAddresses() ->
        172.27.175.255
Effective Client config from environment
    EPICS_PVA_ADDR_LIST="172.27.175.255"
    EPICS_PVA_AUTO_ADDR_LIST=NO
    EPICS_PVA_BROADCAST_PORT=5076
    EPICS_PVA_SERVER_PORT=5075
    EPICS_PVA_CONN_TMO=30
Effective Server config from environment
    EPICS_PVAS_INTF_ADDR_LIST="[::]"
    EPICS_PVAS_BEACON_ADDR_LIST="172.27.175.255"
    EPICS_PVAS_IGNORE_ADDR_LIST=""
    EPICS_PVAS_AUTO_BEACON_ADDR_LIST=NO
    EPICS_PVAS_SERVER_PORT=5075
    EPICS_PVAS_BROADCAST_PORT=5076
    EPICS_PVA_CONN_TMO=30

Additional context The problem is investigated and a fix proposal is ready. We could support in pushing the upstream and launch a pull-request to review. Please let us know you preference.

mdavidsaver commented 1 year ago

Confirmed. I think this issue should be fixed by abeb78a9cdf8f316922a35cd03ef30d3ad186ad3 now on the master branch. Can you test?

mdavidsaver commented 1 year ago

I've fairly confident in this fix, which is included in PVXS 1.1.3.

KrMeeus commented 1 year ago

Sorry for the delay, we needed some time to check the proposal. Yes, the fix is solving the reported issue. Thanks for the prompt action !