[ 
https://issues.apache.org/jira/browse/THRIFT-2370?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13909495#comment-13909495
 ] 

Jens Geyer commented on THRIFT-2370:
------------------------------------

Thanks for catching this. 

In fact, after digging into that issue, the entire method was already a very 
fragile construction before I event touched it, because the code _primarily_ 
relied on the type of the constant value, not the declared data type of the 
underlying constant/variable/member. With [this 
patch|^THRIFT-2370_Compiler_SEGFAULTs_generating_HTML_documentation_for_complex_types.patch]
 I virtually rewrote the entire method to fix the code and to add some minor 
enhancements (such as support for referenced constants) along the way. I used 
Nevo's test case from above and a [modified version of 
ConstantsDemo.thrift|^Testcase-enhanced-ConstantsDemo.thrift].

Would be great if you and/or someone else could have a look at it. 




> Compiler SEGFAULTs generating HTML documentation for complex strucre
> --------------------------------------------------------------------
>
>                 Key: THRIFT-2370
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2370
>             Project: Thrift
>          Issue Type: Bug
>          Components: HTML - Compiler
>            Reporter: Nevo Hed
>            Assignee: Jens Geyer
>            Priority: Blocker
>              Labels: constant
>             Fix For: 0.9.2
>
>         Attachments: 
> THRIFT-2370_Compiler_SEGFAULTs_generating_HTML_documentation_for_complex_types.patch,
>  Testcase-enhanced-ConstantsDemo.thrift
>
>
> This was introduced recently
> // To reproduce
> //  Save this file as "x.thrift", then compile with 
> //     "thrift --gen html x.thrift"
> // 
> // Here is my reproduction with master and 0.9.1
> //  $ /home/nhed/Projects/thrift/compiler/cpp/thrift --version
> //  Thrift version 1.0.0-dev
> //
> //  $ /home/nhed/Projects/thrift/compiler/cpp/thrift --gen html x.thrift
> //  Segmentation fault (core dumped)
> //
> //  $ thrift --version
> //  Thrift version 0.9.1
> //
> //  $ thrift --gen html x.thrift
> //  <no issue>
> struct myMapping { 1: required map<i32, list<i32> > theMap }
> struct myStruct  { 1: required myMapping defMap = {'theMap' :{ 44 : [ 5 ] } } 
> }
> Notice that the value of "type" is not a valid pointer in the top stack frame
> #0  t_html_generator::print_const_value (this=0x875810, type=0x20, 
> tvalue=<value optimized out>) at src/generate/t_html_generator.cc:636
> #1  0x0000000000540d7d in t_html_generator::print_const_value (this=0x875810, 
> type=0x875030, tvalue=<value optimized out>) at 
> src/generate/t_html_generator.cc:621
> #2  0x0000000000540d7d in t_html_generator::print_const_value (this=0x875810, 
> type=0x860170, tvalue=<value optimized out>) at 
> src/generate/t_html_generator.cc:621
> #3  0x00000000005411aa in t_html_generator::generate_struct (this=0x875810, 
> tstruct=0x875120) at src/generate/t_html_generator.cc:808
> #4  0x0000000000544a01 in t_html_generator::generate_program (this=0x875810) 
> at src/generate/t_html_generator.cc:302
> #5  0x00000000004057b9 in generate (program=0x85f770, 
> generator_strings=std::vector of length 1, capacity 1 = {...}) at 
> src/main.cc:1013
> #6  0x0000000000408610 in main (argc=4, argv=0x7fffffffe728) at 
> src/main.cc:1197



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to