You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (JIRA)" <ji...@apache.org> on 2014/04/13 00:52:15 UTC

[jira] [Updated] (THRIFT-2462) prevent possible stack overflow due to recursive syntax support

     [ https://issues.apache.org/jira/browse/THRIFT-2462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jens Geyer updated THRIFT-2462:
-------------------------------

    Description: 
{code:title=Test.Thrift}
namespace * Thrift.Test

struct Foo {
  1: Bar bar
}

struct Bar {
  1: Foo foo 
}

service ThriftTest
{
  i32 testRecursive(1: Foo foo);
}
{code}

{code:title=TestClient.cs}
var first = new Foo()
{
	Bar = new Bar()
	{
		Foo = new Foo()
		{
			Bar = new Bar()
			{
				Foo = null
			}
		}
	}
};

Console.Write("testRecursive(tree)");
Console.WriteLine(" = {0}", client.testRecursive(first));


Console.Write("testRecursive(ring)");
first.Bar.Foo.Bar.Foo = first;  // now let the innermost leaf backpoint to the root node
Console.WriteLine(" = {0}", client.testRecursive(first));
{code}

{code:title=output}
testRecursive(tree) = 4
testRecursive(ring)
Process is terminated due to StackOverflowException.
{code}


  was:
{code.title=Test.Thrift}
namespace * Thrift.Test

struct Foo {
  1: Bar bar
}

struct Bar {
  1: Foo foo 
}

service ThriftTest
{
  i32 testRecursive(1: Foo foo);
}
{code}

{code.title=TestClient.cs}
            var first = new Foo()
            {
                Bar = new Bar()
                {
                    Foo = new Foo()
                    {
                        Bar = new Bar()
                        {
                            Foo = null
                        }
                    }
                }
            };

            Console.Write("testRecursive(tree)");
            Console.WriteLine(" = {0}", client.testRecursive(first));


            Console.Write("testRecursive(ring)");
            first.Bar.Foo.Bar.Foo = first;  // now let the innermost leaf backpoint to the root node
            Console.WriteLine(" = {0}", client.testRecursive(first));
{code}

{code.title=output}
testRecursive(tree) = 4
testRecursive(ring)
Process is terminated due to StackOverflowException.
{code}



> prevent possible stack overflow due to recursive syntax support
> ---------------------------------------------------------------
>
>                 Key: THRIFT-2462
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2462
>             Project: Thrift
>          Issue Type: Improvement
>          Components: C# - Compiler, Delphi - Compiler
>    Affects Versions: 0.9.2
>            Reporter: Jens Geyer
>              Labels: graph
>
> {code:title=Test.Thrift}
> namespace * Thrift.Test
> struct Foo {
>   1: Bar bar
> }
> struct Bar {
>   1: Foo foo 
> }
> service ThriftTest
> {
>   i32 testRecursive(1: Foo foo);
> }
> {code}
> {code:title=TestClient.cs}
> var first = new Foo()
> {
> 	Bar = new Bar()
> 	{
> 		Foo = new Foo()
> 		{
> 			Bar = new Bar()
> 			{
> 				Foo = null
> 			}
> 		}
> 	}
> };
> Console.Write("testRecursive(tree)");
> Console.WriteLine(" = {0}", client.testRecursive(first));
> Console.Write("testRecursive(ring)");
> first.Bar.Foo.Bar.Foo = first;  // now let the innermost leaf backpoint to the root node
> Console.WriteLine(" = {0}", client.testRecursive(first));
> {code}
> {code:title=output}
> testRecursive(tree) = 4
> testRecursive(ring)
> Process is terminated due to StackOverflowException.
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)