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

Jens Geyer resolved THRIFT-6341.
--------------------------------
    Fix Version/s: 0.26.0
         Assignee: Sylwester Lachiewicz
       Resolution: Fixed

> D generator writes a service's exception aliases in pointer order
> -----------------------------------------------------------------
>
>                 Key: THRIFT-6341
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6341
>             Project: Thrift
>          Issue Type: Bug
>          Components: D - Compiler
>    Affects Versions: 0.25.0
>            Reporter: Sylwester Lachiewicz
>            Assignee: Sylwester Lachiewicz
>            Priority: Minor
>             Fix For: 0.26.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> [t_d_generator::generate_service|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_d_generator.cc#L238]
>  collects the exception types a service's functions throw in a 
> {{std::set<t_type*>}} and then writes one {{alias}} line per element in set 
> order, which is the order of the objects' addresses. For a service whose 
> functions throw two or more exception types, the order of those lines can 
> differ between runs and between builds of the compiler, so the generated D is 
> not reproducible.
> {code}
> exception E1 { 1: string msg }
> exception E2 { 1: string msg }
> service Svc { void a() throws (1: E1 e), void b() throws (1: E2 e, 2: E1 f) }
> {code}
> {noformat}
> $ thrift --gen d repro.thrift && grep alias gen-d/Svc.d
>   alias repro_types.E1 E1;
>   alias repro_types.E2 E2;
> {noformat}
> The order depends on the allocator; on this machine it happened to be 
> declaration order. The fix is to keep first-seen order (a vector plus a set 
> for deduplication) or to sort by name. Reproduced on master at 3af0cfff1.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to