pistacheio / pistache

A high-performance REST toolkit written in C++
https://pistacheio.github.io/pistache/
Apache License 2.0
3.18k stars 698 forks source link

“stack smashing detected” error when processing Get requests via generated-cpp-pistache-server #1220

Closed danielmeng1986 closed 2 months ago

danielmeng1986 commented 2 months ago

I generated generated-cpp-pistache-server with openapi-generator-7.7.0. I haven't written any concrete implementation yet, just adding a few standard outputs for debugging purposes.

When testing /getkey, /setkey, /delkey, I can confirm from the output that all parameters are available. But with each request, it makes the server end with the following error:

*** stack smashing detected ***: terminated
Aborted

Here is my customized openapi.yaml.

openapi: 3.0.0
info:
  title: PistacheIO Middleware API
  description: API for PistacheIO Middleware
  version: 1.0.0

servers:
  - url: http://localhost:8889

paths:
  /setkey:
    post:
      summary: Set a key-value pair in Redis
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - key
              - value
              properties:
                key:
                  type: string
                value:
                  type: string
            example:
              key: "exampleKey"
              value: "exampleValue 3355"
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: integer
                    example: 0
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: "invalid JSON"
  /getkey:
    get:
      summary: Get the value of a key from Redis
      parameters:
        - name: key
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  key:
                    type: string
                    example: "exampleKey"
                  value:
                    type: string
                    example: "exampleValue"
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: "not found"
  /delkey:
    delete:
      summary: Delete a key from Redis
      parameters:
        - name: key
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: integer
                    example: 0
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: "delete failed"

using command

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i openapi.yaml -g cpp-pistache-server -o generated-cpp-pistache-server

to generate a cpp-pistacheio-server.

Should I choose a lower version of openapi-generator, or is there something wrong with my compiler?

kiplingw commented 2 months ago

Thanks @danielmeng1986. We didn't write openapi-generator-cli. But to be sure on whether it's a problem with Pistache or incorrect user code, could you provide us with a minimal?

danielmeng1986 commented 2 months ago
            Thank you very much for your help! The Openapi.yaml file I'm using is an example of a pet store.Gesendet mit der WEB.DE Mail AppAm 22.07.24 um 18:38 schrieb Kip

                Von: "Kip" ***@***.***>Datum: 22. Juli 2024An: "pistacheio/pistache" ***@***.***>Cc: "Mention" ***@***.***>,"danielmeng1986" ***@***.***>Betreff: Re: [pistacheio/pistache] “stack smashing detected” error when processing Get requests via generated-cpp-pistache-server (Issue #1220)

Thanks @danielmeng1986. We didn't write openapi-generator-cli. But to be sure on whether it's a problem with Pistache or incorrect user code, could you provide us with a minimal?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

danielmeng1986 commented 2 months ago

Thanks @danielmeng1986. We didn't write openapi-generator-cli. But to be sure on whether it's a problem with Pistache or incorrect user code, could you provide us with a minimal?

To avoid problems with the openapi.yaml file, I actually chose a sample file. From this link: https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml

danielmeng1986 commented 2 months ago

Hier is the generated sourcecode of cpp-pistache-server. I hope this helps you guys help me analyze, what went wrong. generated-cpp-pistache-server.zip

danielmeng1986 commented 2 months ago

Thank you very much for your help! The Openapi.yaml file I'm using is an example of a pet store.Gesendet mit der WEB.DE Mail AppAm 22.07.24 um 18:38 schrieb Kip Von: "Kip" @.>Datum: 22. Juli 2024An: "pistacheio/pistache" @.>Cc: "Mention" @.>,"danielmeng1986" @.>Betreff: Re: [pistacheio/pistache] “stack smashing detected” error when processing Get requests via generated-cpp-pistache-server (Issue #1220) Thanks @danielmeng1986. We didn't write openapi-generator-cli. But to be sure on whether it's a problem with Pistache or incorrect user code, could you provide us with a minimal? —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

Today we did more testing, and we found that the builds would not run on WSL, but would run on native Linux systems, such as Ubuntu.

kiplingw commented 2 months ago

Unfortunately we don't support legacy systems and encourage you to consider upgrading to a GNU/Linux system. Ubuntu, Debian, etc. are all great options with many distros already shipping pre-built Pistache binaries. We've had people periodically ask over the years about Windows and it's just not worth the time and effort to port it when people really shouldn't be running anything important on it to begin with.