1
我在進程運行時遇到了一個段錯誤,這是隨機的,但是觀察到,只有當我用更多的3線程,與另一個點燃節點。多線程C++點火過程中std :: basicstring的運行時段錯誤
這裏是我使用的代碼:
namespace ignite
{
struct CacheSubData
{
std::string data1;
char IMSI[21];
CacheSubData() :
data1()
{
// No-op.
data1.assign(1024, 'b');
sprintf(IMSI, "");
}
};
struct CacheData
{
std::string data;
char TxnNumber[50];
int count;
CacheSubData mCacheSubData;
CacheData() :
data()
{
// No-op.
data.assign(1024, 'a');
sprintf(TxnNumber, "abcdefghijklmnopqrstuvwxyz1234567890");
count = 100;
}
};
}
namespace ignite
{
namespace binary
{
template <>
struct BinaryType<CacheSubData>
{
IGNITE_BINARY_GET_TYPE_ID_AS_HASH("CacheSubData")
IGNITE_BINARY_GET_TYPE_NAME_AS_IS("CacheSubData")
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
static int32_t GetHashCode(ignite::CacheSubData obj)
{
return 0;
}
static bool IsNull(ignite::CacheSubData obj)
{
return false;
}
static void GetNull(ignite::CacheSubData& dst)
{
dst = ignite::CacheSubData();
}
static void Write(BinaryWriter& writer, const ignite::CacheSubData& obj)
{
writer.WriteString("IMSI", obj.IMSI);
}
static void Read(BinaryReader& reader, ignite::CacheSubData& dst)
{
sprintf(dst.IMSI, "%s", (char*)reader.ReadString("IMSI").data());
}
};
template <>
struct BinaryType<CacheData>
{
IGNITE_BINARY_GET_TYPE_ID_AS_HASH("CacheData")
IGNITE_BINARY_GET_TYPE_NAME_AS_IS("CacheData")
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
static int32_t GetHashCode(ignite::CacheData obj)
{
return 0;
}
static bool IsNull(ignite::CacheData obj)
{
return false;
}
static void GetNull(ignite::CacheData& dst)
{
dst = ignite::CacheData();
}
static void Write(BinaryWriter& writer, const ignite::CacheData& obj)
{
writer.WriteInt32("count", obj.count);
writer.WriteString("TxnNumber", obj.TxnNumber);
BinaryType<CacheSubData>::Write(writer, obj.mCacheSubData);
}
static void Read(BinaryReader& reader, ignite::CacheData& dst)
{
dst.count = reader.ReadInt32("count");
sprintf(dst.TxnNumber, "%s", (char*)reader.ReadString("TxnNumber").data());
BinaryType<CacheSubData>::Read(reader, dst.mCacheSubData);
}
};
}
}
由JVM拋出的錯誤是:
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007ff4b8373f48, pid=32201, tid=0x00007ff462309700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_131-b11) (build 1.8.0_131-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libstdc++.so.6+0xbef48] std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)+0x18
#
# Core dump written. Default location: /home/ignite/core or core.32201
#
# An error report file with more information is saved as:
# /home/ignite/hs_err_pid32201.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
它創建於通過發現這些堆棧跟蹤做斷裂核心文件:
#0 0x00007ff4b7a111d7 in raise() from /lib64/libc.so.6
#1 0x00007ff4b7a128c8 in abort() from /lib64/libc.so.6
#2 0x00007ff4b730f3b5 in os::abort(bool)() from /usr/java/default/jre/lib/amd64/server/libjvm.so
#3 0x00007ff4b74b1673 in VMError::report_and_die()() from /usr/java/default/jre/lib/amd64/server/libjvm.so
#4 0x00007ff4b73148bf in JVM_handle_linux_signal() from /usr/java/default/jre/lib/amd64/server/libjvm.so
#5 0x00007ff4b730ae13 in signalHandler(int, siginfo*, void*)() from /usr/java/default/jre/lib/amd64/server/libjvm.so
#6 <signal handler called>
#7 0x00007ff4b8373f48 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)() from /lib64/libstdc++.so.6
#8 0x00007ff4b87f3ff7 in ignite::impl::binary::BinaryTypeSnapshot::BinaryTypeSnapshot (this=0x7ff47c028bd0, another=...)
at src/impl/binary/binary_type_snapshot.cpp:39
#9 0x00007ff4b87f1530 in ignite::impl::binary::BinaryTypeHandler::OnFieldWritten (this=0x7ff47c028a40, [email protected]=94851343,
fieldName="count", [email protected]=3) at src/impl/binary/binary_type_handler.cpp:40
#10 0x00007ff4b87f28cc in ignite::impl::binary::BinaryWriterImpl::WriteFieldId ([email protected]=0x7ff462308b90,
[email protected]=0x404e40 "count", [email protected]=3) at src/impl/binary/binary_writer_impl.cpp:682
#11 0x00007ff4b87f2fc0 in WritePrimitive<int> (func=<optimized out>, typ=3 '\003', len=4, val=100, fieldName=0x404e40 "count",
this=0x7ff462308b90) at ./include/ignite/impl/binary/binary_writer_impl.h:868
#12 ignite::impl::binary::BinaryWriterImpl::WriteInt32 (this=0x7ff462308b90, fieldName=0x404e40 "count", val=100)
at src/impl/binary/binary_writer_impl.cpp:140
#13 0x0000000000404b27 in ignite::impl::In2Operation<double, ignite::CacheData>::ProcessInput(ignite::impl::binary::BinaryWriterImpl&)()
#14 0x00007ff4b8c34d81 in ignite::impl::interop::InteropTarget::WriteTo ([email protected]=0x7ff47c028050, mem=0x7ff47c0265c0, inOp=...,
err=...) at src/impl/interop/interop_target.cpp:54
#15 0x00007ff4b8c3525a in ignite::impl::interop::InteropTarget::OutOp (this=0x7ff47c028050, opType=26, inOp=..., err=...)
at src/impl/interop/interop_target.cpp:94
#16 0x000000000040406e in func(void*)()
#17 0x00007ff4b8e48dc5 in start_thread() from /lib64/libpthread.so.0
#18 0x00007ff4b7ad376d in clone() from /lib64/libc.so.6
不熟悉點火,但我會想象一個[mcve]應該有可能嗎? 'std :: basic_string'是'std :: string' btw –
只是猜測,字符串copy-constructor的字符串參數是無效的。至於爲什麼,至少沒有檢查一些代碼,很難說。 –
您的Ignite版本是什麼? – isapego