[interprocess] Ticket 9414 (32 process communicating with 64 process)
I ran into a problem with message queues that, after a couple of days investigation, lead to finding this bug. I notice that the maintainer has labelled this bug as 'invalid'. I would like to convince the maintainer otherwise. My alternatives are less optimum. I am working on a project where, on a Windows machine, I am running a service that waits for messages on the message queue. On a 32-bit environment, I will not run into any problems. But in a 64-bit environment, I may have either 64-bit or 32-bit clients attempting to write to the message queue, due to the nature of my needs and the nature of the Windows operating system. The messages from the clients are not specific to the bit-ness of the client, but are sent to the server. The server records these messages to a database it maintains. The server then pulls messages from the database and posts it to a web page. As the code stands now, I will have to compile both a 32-bit and 64-bit version of the server to install on 64-bit WinOS boxes, maintaining two separate databases of similar information, which will post to the web site with no sense of co-ordination (and little hope of co-ordination since they can't talk to each other). Or, alternatively, I would have to create my own message queue that doesn't rely upon std::size_t, but perhaps uses boost::uint32_t or boost::uint64_t instead... but it seems silly to me to maintain another message queue when this one is very close to being able to do what I need. I should also point out that I need for this to work in Linux as well, although I don't expect Linux has the Windows annoyance of having to work with two different bit-wise operating systems on one box. At the very least, I'd like a dialog, so I can understand why this defect is considered 'invalid'. Convince me that it really is invalid, and I'll go away. Otherwise, I respectfully argue against it. - Trey
El 18/06/2014 17:03, Joseph Van Riper escribió:
I ran into a problem with message queues that, after a couple of days investigation, lead to finding this bug. I notice that the maintainer has labelled this bug as 'invalid'. I would like to convince the maintainer otherwise. My alternatives are less optimum.
It's strange that I closed it without any comment. I can't remember why I would do that, but that's clearly not the way to close a ticket. Sorry for that.
Or, alternatively, I would have to create my own message queue that doesn't rely upon std::size_t, but perhaps uses boost::uint32_t or boost::uint64_t instead... but it seems silly to me to maintain another message queue when this one is very close to being able to do what I need.
I should also point out that I need for this to work in Linux as well, although I don't expect Linux has the Windows annoyance of having to work with two different bit-wise operating systems on one box.
The problem with the message queue is that it won't work at all in Linux
between 32 and 64 bit processes because this message queue is based on
process-shared mutex and condition variables and pthread mutex and
condition variables provided by glibc are not compatible between 32 and
64 bit processes.
Changing types to It might work on Windows or Solaris, but there is no
guarantee. Message queue members could be differently placed by the 32
or the 64 bit compilers. This class is less than prepared to be shared
between 32 and 64 bit processes.
You can try this using
boost::interprocess::message_queue_t< offset_ptr
At the very least, I'd like a dialog, so I can understand why this defect is considered 'invalid'. Convince me that it really is invalid, and I'll go away. Otherwise, I respectfully argue against it.
The alternative to have a portable message queue is to implement it over POSIX message queues (which uses system calls) on Unix systems and implement a similar interface over Windows named pipes or similar. Not trivial to achieve. In general I regret putting message_queue in Interprocess, as IMHO it's not good enough to be in the library. Some people find it useful, though. Best, Ion
On Wed, Jun 18, 2014 at 4:56 PM, Ion Gaztañaga
El 18/06/2014 17:03, Joseph Van Riper escribió:
It's strange that I closed it without any comment. I can't remember why I
would do that, but that's clearly not the way to close a ticket. Sorry for that.
Ah, well, I suppose sometimes we get in a hurry. Or distracted by something else that's shiny and interesting. Heh.
The problem with the message queue is that it won't work at all in Linux between 32 and 64 bit processes because this message queue is based on process-shared mutex and condition variables and pthread mutex and condition variables provided by glibc are not compatible between 32 and 64 bit processes.
Ugh. I do want something that will work well on Linux as well. I've
learned that Linux, like Windows, can accommodate processes in either 32-bit or 64-bit architectures on a 64-bit machine. If my employer wants to support 64-bit systems (and I think they do, if not immediately), they must consider this issue.
The alternative to have a portable message queue is to implement it over POSIX message queues (which uses system calls) on Unix systems and implement a similar interface over Windows named pipes or similar. Not trivial to achieve.
In general I regret putting message_queue in Interprocess, as IMHO it's not good enough to be in the library. Some people find it useful, though.
It's still useful for my needs, just not quite as elegant as I would like. I can successfully deliver information across platforms in a relatively simple fashion. I just have to use two different servers for that purpose. I am tempted, now, to try and build one that does what I want. I can either do this using the time I spend working towards my needs at my job, or I can try to do this at home, where I can then freely donate the code to boost if the community deems it worthy. I don't think I'm the only person who needs this, given that someone else wrote that defect. I have a lot to learn, though. In any event, thank you very much for your thoughtful response. It gives me much to consider. - Trey
On Thu, Jun 19, 2014 at 12:56 AM, Ion Gaztañaga
The problem with the message queue is that it won't work at all in Linux between 32 and 64 bit processes because this message queue is based on process-shared mutex and condition variables and pthread mutex and condition variables provided by glibc are not compatible between 32 and 64 bit processes.
Interesting. Do you think it is possible to use futexes directly to implement this portability? This would be a Linux-specific solution, of course.
El 19/06/2014 16:20, Andrey Semashev escribió:
On Thu, Jun 19, 2014 at 12:56 AM, Ion Gaztañaga
wrote: The problem with the message queue is that it won't work at all in Linux between 32 and 64 bit processes because this message queue is based on process-shared mutex and condition variables and pthread mutex and condition variables provided by glibc are not compatible between 32 and 64 bit processes.
Interesting. Do you think it is possible to use futexes directly to implement this portability? This would be a Linux-specific solution, of course.
Futexes take a int pointer and in Linux int is 32 bits in both 32 and 64 bit processes (I think it uses the LP64 data model). So yes, that would be possible, but quite hard to implement, as futexes are quite tricky. I would accept patches, though ;-) We can also test if using spin_condition/spin_mutex is enough from a performance point of view. Those are implemented with basic atomic operations and waits, but operating in 32 bit integers. That could be portable in all OS if correct alignments are used. Best, Ion
participants (3)
-
Andrey Semashev
-
Ion Gaztañaga
-
Joseph Van Riper