Skip to content

Conversation

@sinny-sama
Copy link

reproducible with following:

[root@vostro tmp]# cat test.c
#include <stdio.h>
#include <stdlib.h>

#include <tarantool/tarantool.h>
#include <msgpuck.h>

void test(int levels)
{
struct tnt_stream s;
tnt_object(&s);
tnt_object_type(&s, TNT_SBO_SPARSE);

    for (int i=0; i<levels; ++i)
    {
            tnt_object_add_array(&s, 0);
            tnt_object_add_uint(&s, i);
    }

    for (int i=0; i<levels; ++i)
            tnt_object_container_close(&s);

    mp_fprint(stdout, TNT_SBUF_DATA(&s));
printf("\n");

}

int main(int argc, char **argv)
{
for (int i=1; i<argc; ++i)
test(atoi(argv[i]));
return 0;
}
[root@vostro tmp]#

[root@vostro tmp]# gcc test.c -o test /usr/lib64/libmsgpuck.a /usr/lib64/libtarantool.a

[root@vostro tmp]# ./test 8
[0, [1, [2, [3, [4, [5, [6, [7]]]]]]]]
[root@vostro tmp]#

[root@vostro tmp]# ./test 9
[]
[root@vostro tmp]#

if tnt_sbuf_object_grow_stack() gets called (effectively overwriting
current stack array with zeroes)

reproducible with following:
----------------------------
[root@vostro tmp]# cat test.c
\#include <stdio.h>
\#include <stdlib.h>

\#include <tarantool/tarantool.h>
\#include <msgpuck.h>

void test(int levels)
{
        struct tnt_stream s;
        tnt_object(&s);
        tnt_object_type(&s, TNT_SBO_SPARSE);

        for (int i=0; i<levels; ++i)
        {
                tnt_object_add_array(&s, 0);
                tnt_object_add_uint(&s, i);
        }

        for (int i=0; i<levels; ++i)
                tnt_object_container_close(&s);

        mp_fprint(stdout, TNT_SBUF_DATA(&s));
	printf("\n");
}

int main(int argc, char **argv)
{
	for (int i=1; i<argc; ++i)
		test(atoi(argv[i]));
	return 0;
}
[root@vostro tmp]#

[root@vostro tmp]# gcc test.c -o test /usr/lib64/libmsgpuck.a /usr/lib64/libtarantool.a

[root@vostro tmp]# ./test 8
[0, [1, [2, [3, [4, [5, [6, [7]]]]]]]]
[root@vostro tmp]#

[root@vostro tmp]# ./test 9
[]
[root@vostro tmp]#
----------------------------
@Totktonada Totktonada requested a review from Korablev77 July 7, 2022 10:57
@kyukhin kyukhin removed the request for review from Korablev77 August 4, 2023 08:00
@kyukhin kyukhin requested a review from alyapunov September 8, 2023 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants