zoukankan      html  css  js  c++  java
  • 记录OCI操作一个诡异的问题

    今天稍微改了下主线版本的代码,不知从何时起,后台关闭会crash掉,报错如下:

    ORA-24550: signal received: [si_signo=6] [si_errno=0] [si_code=-6] [si_int=0] [si_ptr=(nil)] [si_addr=0x3ec00003fb5]

    kpedbg_dmp_stack()+362<-kpeDbgCrash()+192<-kpeDbgSignalHandler()+119<-skgesig_sigactionHandler()+218<-__sighandler()<-gsignal()+55<-malloc_consolidate()+1029

    仔细检查代码,并未改动和oci操作相关的代码,只是加了一些日志输出的内容,经过仔细排查对比发现是由于

    使用了一段字符串trim的代码导致:

    1. std::string& trim(std::string &s)   
    2. {  
    3.     if (s.empty())   
    4.     {  
    5.         return s;  
    6.     }  
    7.     
    8.     s.erase(0,s.find_first_not_of(" "));  
    9.     s.erase(s.find_last_not_of(" ") + 1);  
    10.     return s;  
    11. }  

    换成另外一个实现问题就没出现了:

    std::string str_trim(std::string &str)

    {

        string::size_type pos = str.find_first_not_of(' ');

        if (pos == string::npos)

        {

            return str;

        }

        string::size_type pos2 = str.find_last_not_of(' ');

        if (pos2 != string::npos)

        {

            return str.substr(pos, pos2 - pos + 1);

        }

        return str.substr(pos);

    }

  • 相关阅读:
    C语言I博客作业05
    C语言I博客作业04
    C语言II博客作业01
    学期总结
    第一周作业
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
    C语言I博客作业05
    C语言I博客作业04
  • 原文地址:https://www.cnblogs.com/skiing886/p/7927892.html
Copyright © 2011-2022 走看看