c++ - 多线程 C++ 点火过程中 std::basicstring 的运行时段错误

标签 c++ ignite

我在进程运行时面临段错误,这是随机的,但观察到只有当我启动进程时有超过 3 个线程,并且另一个点燃节点启动时才会发生这种情况。

这是我正在使用的代码:

    namespace ignite
{
 struct CacheSubData
   {
   std::string data1;
   char IMSI[21];
   CacheSubData() :
 data1()
   {
 // No-op.
 data1.assign(1024, 'b');
 sprintf(IMSI, "9876543210");
   }
   };

   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, fieldId=fieldId@entry=94851343,
fieldName="count", fieldTypeId=fieldTypeId@entry=3) at src/impl/binary/binary_type_handler.cpp:40
#10 0x00007ff4b87f28cc in ignite::impl::binary::BinaryWriterImpl::WriteFieldId (this=this@entry=0x7ff462308b90,
fieldName=fieldName@entry=0x404e40 "count", fieldTypeId=fieldTypeId@entry=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 (this=this@entry=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

最佳答案

好像是known bug它已在 master 中修复,并将包含在即将发布的 2.1 版本中

关于c++ - 多线程 C++ 点火过程中 std::basicstring 的运行时段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44897286/

相关文章:

c++ - Qt:读取 .txt 文件时遇到问题

java - @QuerySqlField 可以用在方法上吗?

apache-spark - Apache Spark与Apache Ignite

c++ - 如何找到 Teechart 图和 Teechart Canvas 的顶部/左侧和顶部/右侧?

c++ - math.h 的问题

c++ - 在结构的 STL 映射中,为什么 "[ ]"运算符会导致结构的 dtor 被额外调用 2 次?

java - springboot缓存自动刷新redis和apache ignite

java - Apache Ignite 节点失败 : Failed to read magic header

java - Intellij Apache Ignite 项目不会生成有效的 JAR 文件

c++ - CListCtrl。当双击总是收到 NM_CLICK + NM_DBLCLK