Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Panic when using -use parameter with multiple Services and Handlers #1686

Open
cqcqfjc opened this issue Feb 1, 2025 · 3 comments
Open

Panic when using -use parameter with multiple Services and Handlers #1686

cqcqfjc opened this issue Feb 1, 2025 · 3 comments
Assignees

Comments

@cqcqfjc
Copy link

cqcqfjc commented Feb 1, 2025

Description:

When using Kitex to generate code with multiple Services and Handlers, specifying the -use parameter causes a runtime panic with a nil pointer dereference error.

Steps to Reproduce:

  1. Create a .thrift file with multiple services defined.
  2. Run the following command to generate code:
kitex -tpl multiple_services -service system -module example -use example/pkg/kitex_gen ./../../idl/rpc/example.thrift
  1. Observe the panic error:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x20 pc=0x100d9b424]

Environment:

  • Kitex Version: v0.12.1
  • Go Version: go1.22.5

Additional Information:

example/pkg/kitex_gen has been generated.

@DMwangnima
Copy link
Contributor

Thx for your feedback on the issue! Can you provide an example kitex_gen that -use is pointing to and the thrift file for easy reproduction?

@cqcqfjc
Copy link
Author

cqcqfjc commented Feb 6, 2025

├── app
│   └── Makefile
├── go.mod
├── go.sum
├── idl
│   └── example.thrift
└── pkg
    └── Makefile

go.mod:

module example

go 1.23.1

idl/example.thrift

struct PingReq{
    1: required string message;
}
struct PingResp{
    1: required string message;
}
service ExampleService {
    PingResp ping(1: PingReq req);
}


struct FooReq{
    1: required string message;
}
struct FooResp{
    1: required string message;
}
service ExampleService2 {
    FooReq foo(1: FooReq req);
}

app/Makefile

gen:
	-kitex -tpl multiple_services -service app -module example -use example/pkg/kitex_gen  ./../idl/example.thrift

pkg/Makefile

gen:
	-kitex -module example ./../idl/example.thrift

Step.1:

cd pkg && make

Step.2:

cd app && make

@DMwangnima DMwangnima self-assigned this Feb 6, 2025
@DMwangnima
Copy link
Contributor

This issue would be solved by this PR #1688

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants