Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

warning about app_thread_info_t.tid not initialized #34

Closed
ptroja opened this issue Jun 9, 2010 · 5 comments
Closed

warning about app_thread_info_t.tid not initialized #34

ptroja opened this issue Jun 9, 2010 · 5 comments

Comments

@ptroja
Copy link
Contributor

ptroja commented Jun 9, 2010

The QNX C++ compiler, which is a bit more restrictive than GCC emits the following warning:
ctx.cpp:153: note: 'info.zmq::ctx_t::app_thread_info_t::tid' was declared here.

While this caused by the call to app_threads.push_back (info); (line 160) because uninitialized value is stored in the container. This value is assigned just few lines below (line169), app_threads [current].tid = thread_t::id ();, so probably it is not a problem.

This can be however be an issue if incidentally some exception would be thrown in the meantime - we would end up with uninitialized data in the container.

I think the solution is to:

  1. provide a initializers to default value in constructor of app_thread_info_t struct
  2. or to initialize tid to some value before storing the data in a container.
    The problem is that this warning (together with -Werror) does not allow for a clean build under QNX.
@zeromq
Copy link
Collaborator

zeromq commented Jun 10, 2010

There's no portable PTHREAD_NULL constant.

Can you check whether zeroing the memory gets rid of the warning?

memset (&info, 0, sizeof (info);

@ptroja
Copy link
Contributor Author

ptroja commented Jun 10, 2010

This is my solution:
http://github.com/ptroja/zeromq2/commit/03a5f0c21a36ffc020f980701bdde370a89c01e0

I have checked that this eliminates the warning (and of course the latency performance test is working with it). If you agree with it - please just do a pull from my branch. This fixup is also MIT licensed.

@zeromq
Copy link
Collaborator

zeromq commented Jun 10, 2010

I don't like the idea of putting bogus thread ID to the structure. It's just begging for problems. Can you check the memset (&into, 0, sizeof (info)) solution?

@ptroja
Copy link
Contributor Author

ptroja commented Jun 10, 2010

Checked, memset() also solves the problem. You can cherry-pick the latest commit from my branch (MIT licensed).

@zeromq
Copy link
Collaborator

zeromq commented Jun 10, 2010

Done. Thanks!

mrvn pushed a commit to mrvn/libzmq that referenced this issue Jul 2, 2015
Solution: backport the latest STDINT definitions from libzmq.

Fixes zeromq#34
benjdero pushed a commit to benjdero/libzmq that referenced this issue Feb 20, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant