OpenAPITools / OpenAPITools/openapi-generator
[BUG] [pistache] stack smashing detected
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
I want to generate a cpp-pistache-server with openapi-generator. But the generated cpp-pistache-server reports “stack smashing detected” error after receiving the request.
openapi-generator version
I downloaded openapi-generator-cli.jar with the command in WSL.
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.7.0/openapi-generator-cli-7.7.0.jar -O openapi-generator-cli.jar
The version of openapi-generator is 7.7.0.
OpenAPI declaration file content or url
The yaml file, I use is the example file from yours, the petstore
Generation Details
I use the follow command to generate resource codes.
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
-g cpp-pistache-server \
-o generated-cpp-pistache-server
Generating the code went well.
Steps to reproduce
When I start the api-server program, it runs on my localhost:8080 port. When I make a GET request, an error occurs.
curl -X GET "http://localhost:8080/pet/0"
Error:
*** stack smashing detected ***: terminated
Aborted
A more detailed report obtained using GDB debugging is:
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737329694272) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=140737329694272) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=140737329694272, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007ffff7a3e476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007ffff7a247f3 in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff7a85676 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7bd792e "*** %s ***: terminated\n")
at ../sysdeps/posix/libc_fatal.c:155
#6 0x00007ffff7b3259a in __GI___fortify_fail (msg=msg@entry=0x7ffff7bd7916 "stack smashing detected") at ./debug/fortify_fail.c:26
#7 0x00007ffff7b32566 in __stack_chk_fail () at ./debug/stack_chk_fail.c:24
#8 0x000055555565cb4c in Pistache::Rest::Routes::bind<void, org::openapitools::server::api::PetApi, Pistache::Rest::Request const&, Pistache::Http::ResponseWriter, org::openapitools::server::api::PetApi*>(void (org::openapitools::server::api::PetApi::*)(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter), org::openapitools::server::api::PetApi*)::{lambda(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter)#1}::operator()(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter) const (__closure=0x55555575e960,
request=..., response=...)
at /home/de00022149/projects/GIT/restapi-test/08.openapi-master/generated-cpp-pistache-server/external/include/pistache/router.h:412
#9 0x0000555555670199 in std::__invoke_impl<Pistache::Rest::Route::Result, Pistache::Rest::Routes::bind<void, org::openapitools::server::api::PetApi, Pistache::Rest::Request const&, Pistache::Http::ResponseWriter, org::openapitools::server::api::PetApi*>(void (org::openapitools::server::api::PetApi::*)(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter), org::openapitools::server::api::PetApi*)::{lambda(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter)#1}&, Pistache::Rest::Request, Pistache::Http::ResponseWriter>(st--Type <RET> for more, q to quit, c to continue without paging--
d::__invoke_other, Pistache::Rest::Routes::bind<void, org::openapitools::server::api::PetApi, Pistache::Rest::Request const&, Pistache::Http::ResponseWriter, org::openapitools::server::api::PetApi*>(void (org::openapitools::server::api::PetApi::*)(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter), org::openapitools::server::api::PetApi*)::{lambda(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter)#1}&, Pistache::Rest::Request&&, Pistache::Http::ResponseWriter&&) (__f=...) at /usr/include/c++/11/bits/invoke.h:61
#10 0x0000555555668ff8 in std::__invoke_r<Pistache::Rest::Route::Result, Pistache::Rest::Routes::bind<void, org::openapitools::server::api::PetApi, Pistache::Rest::Request const&, Pistache::Http::ResponseWriter, org::openapitools::server::api::PetApi*>(void (org::openapitools::server::api::PetApi::*)(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter), org::openapitools::server::api::PetApi*)::{lambda(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter)#1}&, Pistache::Rest::Request, Pistache::Http::ResponseWriter>(Pistache::Rest::Routes::bind<void, org::openapitools::server::api::PetApi, Pistache::Rest::Request const&, Pistache::Http::ResponseWriter, org::openapitools::server::api::PetApi*>(void (org::openapitools::server::api::PetApi::*)(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter), org::openapitools::server::api::PetApi*)::{lambda(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter)#1}&, Pistache::Rest::Request&&, Pistache::Http::ResponseWriter&&) (__fn=...) at /usr/include/c++/11/bits/invoke.h:114
#11 0x0000555555661692 in std::_Function_handler<Pistache::Rest::Route::Result (Pistache::Rest::Request, Pistache::Http::ResponseWriter), Pistache::Rest::Routes::bind<void, org::openapitools::server::api::PetApi, Pistache::Rest::Request const&, Pistache::Http::ResponseWriter, org::openapitools::server::api::PetApi*>(void (org::openapitools::server::api::PetApi::*)(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter), org::openapitools::server::api::PetApi*)::{lambda(Pistache::Rest::Request const&, Pistache::Http::ResponseWriter)#1}>::_M_invoke(std::_Any_data const&, Pistache::Rest::Request&&, Pistache::Http::ResponseWriter&&) (__functor=..., __args#0=...,
__args#1=...) at /usr/include/c++/11/bits/std_function.h:290
#12 0x00007ffff7f602de in Pistache::Rest::Router::route(Pistache::Http::Request const&, Pistache::Http::ResponseWriter) ()
--Type <RET> for more, q to quit, c to continue without paging--
from /usr/local/lib/libpistache.so.0
#13 0x00007ffff7f614b6 in Pistache::Rest::Private::RouterHandler::onRequest(Pistache::Http::Request const&, Pistache::Http::ResponseWriter) () from /usr/local/lib/libpistache.so.0
#14 0x00007ffff7f0629c in Pistache::Http::Handler::onInput(char const*, unsigned long, std::shared_ptr<Pistache::Tcp::Peer> const&) ()
from /usr/local/lib/libpistache.so.0
#15 0x00007ffff7f3e35b in Pistache::Tcp::Transport::handleIncoming(std::shared_ptr<Pistache::Tcp::Peer> const&) ()
from /usr/local/lib/libpistache.so.0
#16 0x00007ffff7f43665 in Pistache::Tcp::Transport::onReady(Pistache::Aio::FdSet const&) () from /usr/local/lib/libpistache.so.0
#17 0x00007ffff7f39123 in Pistache::Aio::SyncImpl::runOnce() () from /usr/local/lib/libpistache.so.0
#18 0x00007ffff7f362f2 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<Pistache::Aio::AsyncImpl::Worker::run()::{lambda()#1}> > >::_M_run() () from /usr/local/lib/libpistache.so.0
#19 0x00007ffff7d21253 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#20 0x00007ffff7a90ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#21 0x00007ffff7b22850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Related issues/PRs
Suggest a fix
Should I choose a lower version of openapi-generator, or is there something wrong with my compiler?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by generating the cpp-pistache-server from the linked petstore.yaml using openapi-generator-cli 7.7.0, then reproduce the request that reports “stack smashing detected.” Inspect the generated server and the cpp-pistache generator entry points to identify where the failure occurs; done means the generated server handles the request without the stack-smashing error and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, java
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100