AMQP-CPP/include
javeme 5c3ba7b00a Program crashes when receiving a message due to memory corruption
crashes due to the wrong way using aligned_storage.

Steps to reproduce:
1. Start a consumer
  channel.consume(queue, tag).onMessage(msgCallback)
2. Send a message to the consumer
3. The program crashes

Environment:
Windows 7 / VS2010

The reason:
The Windows prompted to memory corruption, I found some strange phenomenon
about stack_ptr<Message>, such as:
  1.sizeof(stack_ptr<Message>) is equal to 2
  2.stack_ptr._initialized becomes true after construct() called (actually,
    it never has been assigned true, please see [1])

Finally I found that the root cause was stack_ptr._data, we directly used
aligned_storage rather than aligned_storage::type[2] as the type of _data.
so the _data was just an empty struct, and subsequent operations were
performed in illegal memory. It eventually led to the crash.

This patch we fixed the bug and add "_initialized = true" at the end of the
method stack_ptr::construct().

[1] https://github.com/CopernicaMarketingSoftware/AMQP-CPP/blob/master/include/stack_ptr.h#L83
[2] http://www.cplusplus.com/reference/type_traits/aligned_storage/
2016-06-27 02:03:15 +08:00
..
CMakeLists.txt renamed apple.h to endian.h because it turns out that it is also used for linux systems, and removed double implemented ChannelImpl::get() function 2014-08-14 15:25:44 +02:00
address.h When building the address url, username and password should be split with a colon 2015-11-02 17:53:43 +01:00
array.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
booleanset.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
buffer.h small legibility fixes 2016-06-10 15:21:10 +02:00
bytebuffer.h added tcpinbuffer with much less allocation 2016-06-15 13:32:30 -04:00
callbacks.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
channel.h Added TcpChannel class so that Connection and Channel class are once again completely protocol agnostic 2015-11-01 09:51:43 +01:00
channelimpl.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
classes.h moved the #pragma once statement 2015-11-01 10:48:13 +01:00
connection.h added connection::maxFrame() and connection::expected() methods to give hints about the amount of data that the connection::parse() method ideally expects 2016-06-15 04:57:46 -04:00
connectionhandler.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
connectionimpl.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
decimalfield.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
deferred.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
deferredcancel.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
deferredconsumer.h Copied the methods to both implementations so they can return their concrete type 2016-06-23 16:02:04 +02:00
deferredconsumerbase.h Copied the methods to both implementations so they can return their concrete type 2016-06-23 16:02:04 +02:00
deferreddelete.h Bugfix: add missing include guards 2016-04-06 17:49:39 +03:00
deferredget.h Copied the methods to both implementations so they can return their concrete type 2016-06-23 16:02:04 +02:00
deferredqueue.h Bugfix: add missing include guards 2016-04-06 17:49:39 +03:00
endian.h Removed some macros for FreeBSD: Apparantly they are not needed. We might need to remove them for NetBSD and DragonFly as well 2015-07-01 09:48:56 +02:00
entityimpl.h moved the #pragma once statement 2015-11-01 10:48:13 +01:00
envelope.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
exchangetype.h added consistent-hash exchange (same as pull request #68) 2016-06-15 11:20:31 -04:00
field.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
fieldproxy.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
flags.h added "override" keywords to overridden methods, fixed buffer overflow in setting up a connection 2015-11-28 11:38:15 +01:00
libev.h Fix segfault when the handler is destructed from within a callback 2016-01-15 14:19:09 +01:00
libevent.h add TcpHandler implementation for libevent 2016-01-09 16:03:42 -05:00
login.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
message.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
metadata.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
monitor.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
numericfield.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
outbuffer.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
receivedframe.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
stack_ptr.h Program crashes when receiving a message due to memory corruption 2016-06-27 02:03:15 +08:00
stringfield.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
table.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00
tcpchannel.h Added TcpChannel class so that Connection and Channel class are once again completely protocol agnostic 2015-11-01 09:51:43 +01:00
tcpconnection.h added tcpinbuffer with much less allocation 2016-06-15 13:32:30 -04:00
tcphandler.h Bugfix: add missing include guards 2016-04-06 17:49:39 +03:00
watchable.h Only allocate a message and its data when a consumer wants to and allow consumers to receive the individual parts 2016-06-23 14:42:50 +02:00