Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

API Blueprint with empty One Of entry causes segmentation fault #699

Closed
kylef opened this issue May 13, 2019 · 0 comments · Fixed by #704
Closed

API Blueprint with empty One Of entry causes segmentation fault #699

kylef opened this issue May 13, 2019 · 0 comments · Fixed by #704
Labels

Comments

@kylef
Copy link
Member

kylef commented May 13, 2019

The following API Blueprint which has an empty One Of entry causes segmentation fault:

# GET /

+ Request (application/json)
    + Attributes
        + One Of
            + 
$ drafter document.apib
terminated by signal SIGSEGV (Address boundary error)
$ drafter --version
v4.0.0-pre.5
Process 98591 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x000000010005c6e9 drafter`refract::dsd::Option::Option(refract::dsd::Option const&) [inlined] refract::dsd::Option::Option(el=0x0000000102345f00)::$_0::operator()(std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > const&) const at Option.cc:52:24 [opt]
   49  	        std::back_inserter(elements_),
   50  	        [](const value_type& el) -> std::unique_ptr<IElement> {
   51  	            assert(el);
-> 52  	            return el->clone();
   53  	        });
   54  	}
   55
Target 0: (drafter) stopped.
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x000000010005c6e9 drafter`refract::dsd::Option::Option(refract::dsd::Option const&) [inlined] refract::dsd::Option::Option(el=0x0000000102345f00)::$_0::operator()(std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > const&) const at Option.cc:52:24 [opt]
    frame #1: 0x000000010005c6e6 drafter`refract::dsd::Option::Option(refract::dsd::Option const&) [inlined] std::__1::back_insert_iterator<std::__1::vector<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> >, std::__1::allocator<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > > > > std::__1::transform<std::__1::__wrap_iter<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > const*>, std::__1::back_insert_iterator<std::__1::vector<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> >, std::__1::allocator<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > > > >, refract::dsd::Option::Option(__first=<unavailable>, __last=<unavailable>, __result=<unavailable>)::$_0>(std::__1::__wrap_iter<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > const*>, std::__1::__wrap_iter<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > const*>, std::__1::back_insert_iterator<std::__1::vector<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> >, std::__1::allocator<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > > > >, refract::dsd::Option::Option(refract::dsd::Option const&)::$_0) at algorithm:1963 [opt]
    frame #2: 0x000000010005c6da drafter`refract::dsd::Option::Option(this=0x00007ffeefbfe378, other=<unavailable>) at Option.cc:47 [opt]
    frame #3: 0x000000010005d151 drafter`refract::Element<refract::dsd::Option>::clone(this=<unavailable>, flags=15) const at Element.h:147:29 [opt]
    frame #4: 0x000000010005cafc drafter`refract::dsd::Select::Select(refract::dsd::Select const&) [inlined] std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > > refract::clone<refract::Element<refract::dsd::Option>, std::__1::enable_if<true, void> >(el=<unavailable>, flags=15) at ElementIfc.h:126:68 [opt]
    frame #5: 0x000000010005caef drafter`refract::dsd::Select::Select(refract::dsd::Select const&) [inlined] refract::dsd::Select::Select(el=0x0000000102345760)::$_0::operator()(std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > > const&) const at Select.cc:54 [opt]
    frame #6: 0x000000010005cae7 drafter`refract::dsd::Select::Select(refract::dsd::Select const&) [inlined] std::__1::back_insert_iterator<std::__1::vector<std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > >, std::__1::allocator<std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > > > > > std::__1::transform<std::__1::__wrap_iter<std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > > const*>, std::__1::back_insert_iterator<std::__1::vector<std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > >, std::__1::allocator<std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > > > > >, refract::dsd::Select::Select(__first=<unavailable>, __last=<unavailable>, __result=<unavailable>)::$_0>(std::__1::__wrap_iter<std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > > const*>, std::__1::__wrap_iter<std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > > const*>, std::__1::back_insert_iterator<std::__1::vector<std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > >, std::__1::allocator<std::__1::unique_ptr<refract::Element<refract::dsd::Option>, std::__1::default_delete<refract::Element<refract::dsd::Option> > > > > >, refract::dsd::Select::Select(refract::dsd::Select const&)::$_0) at algorithm:1963 [opt]
    frame #7: 0x000000010005cadb drafter`refract::dsd::Select::Select(this=0x00007ffeefbfe468, other=<unavailable>) at Select.cc:48 [opt]
    frame #8: 0x000000010005b13f drafter`refract::Element<refract::dsd::Select>::clone(this=<unavailable>, flags=15) const at Element.h:147:29 [opt]
    frame #9: 0x000000010005be85 drafter`refract::dsd::Object::Object(refract::dsd::Object const&) [inlined] refract::dsd::Object::Object(el=<unavailable>)::$_0::operator()(std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > const&) const at Object.cc:47:24 [opt]
    frame #10: 0x000000010005be74 drafter`refract::dsd::Object::Object(refract::dsd::Object const&) [inlined] std::__1::back_insert_iterator<std::__1::vector<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> >, std::__1::allocator<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > > > > std::__1::transform<std::__1::__wrap_iter<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > const*>, std::__1::back_insert_iterator<std::__1::vector<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> >, std::__1::allocator<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > > > >, refract::dsd::Object::Object(__first=<unavailable>, __last=<unavailable>, __result=<unavailable>)::$_0>(std::__1::__wrap_iter<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > const*>, std::__1::__wrap_iter<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > const*>, std::__1::back_insert_iterator<std::__1::vector<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> >, std::__1::allocator<std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > > > >, refract::dsd::Object::Object(refract::dsd::Object const&)::$_0) at algorithm:1963 [opt]
    frame #11: 0x000000010005be68 drafter`refract::dsd::Object::Object(this=0x00007ffeefbfe548, other=<unavailable>) at Object.cc:42 [opt]
    frame #12: 0x00000001000448ab drafter`refract::Element<refract::dsd::Object>::clone(this=<unavailable>, flags=15) const at Element.h:147:29 [opt]
    frame #13: 0x000000010000ef74 drafter`PayloadToRefract(drafter::NodeInfo<snowcrash::Payload> const&, drafter::NodeInfo<snowcrash::Action> const&, drafter::ConversionContext&) [inlined] std::__1::unique_ptr<refract::IElement, std::__1::default_delete<refract::IElement> > refract::clone<refract::IElement, std::__1::enable_if<true, void> >(el=<unavailable>, flags=15) at ElementIfc.h:126:68 [opt]

...
@kylef kylef added the bug label May 13, 2019
tjanc added a commit that referenced this issue May 20, 2019
Fixes #699 by skipping invalid One Of entries when translating MSON to
API Elements.

In the example in #699, the parser (snowcrash) should skip the invalid
One Of even before it arrives in semantic analysis. Because we are planning
a complete rewrite of our parser, this issue was fixed during
semantic analysis (drafter).
kylef pushed a commit that referenced this issue May 20, 2019
Fixes #699 by skipping invalid One Of entries when translating MSON to
API Elements.

In the example in #699, the parser (snowcrash) should skip the invalid
One Of even before it arrives in semantic analysis. Because we are planning
a complete rewrite of our parser, this issue was fixed during
semantic analysis (drafter).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant