Comments (7)
You could try compiling proto file to .pb file (using the official protoc executable and -o flag) first.
Then, try use protoc.new(), it doesn't need global state.
Thirdly, try pb.state(). Use separate state in one thread.
Other parts of lua-protobuf do not modify global state.
from lua-protobuf.
Thank you for the response. I am confused by the relationship of protoc and pb because the APIs never directly connect to each other (e.g. protoc doesn't return any parameters that you pass to pb functions).
If I compile a proto file to .pb (e.g. protoc --descriptor_set_out MyFoo.pb MyFoo.proto), does that let me avoid needing to use protoc?
local fh, err = io.open("MyFoo.pb", "rb")
local file_data = fh:read("*all")
local pb = require("pb")
pb.load(file_data)
Is this what you were suggesting with your first sentence?
Then I wouldn't need to use protoc at all, right? And so I wouldn't need protoc.new(), right?
FYI, each LuaLane creates a new lua_State to run in. So each pb probably gets its own state already, so I don't think I need pb.state() in my case.
Thank you
from lua-protobuf.
If I compile a proto file to .pb (e.g. protoc --descriptor_set_out MyFoo.pb MyFoo.proto), does that let me avoid needing to use protoc?
Yes.
Is this what you were suggesting with your first sentence?
Then I wouldn't need to use protoc at all, right? And so I wouldn't need protoc.new(), right?
Yes.
FYI, each LuaLane creates a new lua_State to run in. So each pb probably gets its own state already, so I don't think I need pb.state() in my case.
Okk, that make sense.
from lua-protobuf.
I haven't gotten any crashes since I made the change to load the .pb and avoid protoc. 👍
I'm just curious, what happens if I pb.load the same descriptor multiple times in the same state? Is this harmless? Is there a reloading cost or does the system know it is already loaded and returns early?
from lua-protobuf.
I spoke too soon. My crashes came back :(
I was looking at the source code in pb.c. There is a global variable called global_state:
Line 131 in 449ad5d
My current hunch is that this may be related to my crashes while using Lanes. I'm thinking I want to try changing this to not use a global variable, to see if it will make my crashes go away. Can you give me any hints on what is involved to change this?
Thanks
from lua-protobuf.
this global just used in pb.state()
routines, you could delete it (and relate codes) and see whether it works.
from lua-protobuf.
My crashes disappeared for a couple of weeks, but just came back.
I tried deleting global_state (and related code), but it didn't fix the problem. So that was a red herring for me.
So now, I think my problem might be caused by something unrelated (I hate threading bugs). But I think this part of lua-protobuf is fine and not the problem. Thanks for your help and time.
from lua-protobuf.
Related Issues (20)
- 当include_imports和unknow_import都为true时,会出现错误
- 希望支持 oneof 的 DefaultMessageDecoding HOT 1
- bad argument #1 to 'encode' (type 'Person' does not exists) HOT 8
- pb.so causes nginx to segfault HOT 4
- 循环引用场景下会导致stack overflow HOT 1
- pb.decode() 导致 out of memory HOT 1
- pb中uint64过长, 在decode时会被科学计数法 HOT 1
- pb.decode 问题。 HOT 1
- Option name expected
- Proto - JSON transcoder HOT 2
- nested message with default values regression HOT 1
- protobuf3 optional: configurable "optional_" prefix HOT 3
- pb.encode double/float 类型数据,在C++里ParseFromString会有问题。 HOT 2
- Decode to a temporary message to extract or change data
- Segfaults with gcc 13 and `-fstrict-aliasing` HOT 12
- 请问下java的.proto文件存在import引用其它文件如何加载 HOT 1
- Running on ESP32: load() function not working HOT 3
- what causes change in state? HOT 1
- loading fail. HOT 1
- Name resolution is failing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-protobuf.