Categories
工作

入职3个月

换了个公司,跟原来公司做的业务相似又不一致,从交易系统转移到了回测平台,稍微总结一下。

  • 多线程、多进程的业务变多了,这部分在之前公司注意的不是特别多,可能需要多留个心眼(虽然C++11开始对多线程比较友好了);
  • 性能优化的方向变了。从原来单线程的纳秒级(或者Cycle级别)做优化,换到现在数据量上去、可以做并发的优化。不过基本的套路还是在的,对底层的东西要熟悉,另外逻辑也要开拓;
  • 施展空间大了。原来的公司系统各个组件之间的分别已经很明显,接口什么的交互手段也差不多了,现在的公司新的东西比较多,容易接到一些好玩的“造轮子”项目;
  • Python。原来也写Python,但是仅限于小工具。新公司各种Python/C++接口,也算锻炼人。

对未来的自己:

  • 多看一些,多想一些,凡事留个心眼,小步快走(我TM怎么觉得我已经老了);
  • 不能太低调,要尽力“推销”自己的成果
Categories
工作

Protected: 测试很关键!

This content is password protected. To view it please enter your password below:

Categories
工作

No core will be dumped when calling exit() in a signal handler

The customized abnormal signal handler (e.g. SIGSEGV handler) will function abnormally if we call exit() inside the handler: the program will exit “as normal” however it did had some severe memory issue.
See code snippet below, try to run with / without “X” argument.

/* exit example */
#include <stdio.h>      /* printf, fopen */
#include <stdlib.h>     /* exit, EXIT_FAILURE */
#include <signal.h>     /* signal */
#include <string.h>
bool disable_exit = false;
void InitiateAbnormalShutdown()
{
    printf("ABNORMAL SHUTDOWN!!!\n");
    if (!disable_exit)
        exit(EXIT_FAILURE);
}
void AbnormalSignalHandler(int signo)
{
    signal(signo, SIG_DFL);
    InitiateAbnormalShutdown();
    raise(signo);
}
bool give_me_an_error()
{
    int* test = new int;
    *test = 500;
    delete test;
    test = NULL;
    *test = 900;
    if (*test > 500)
    {
        return false;
    }
    return true;
}
int main(int argc, char *argv[])
{
    if (argc > 1)
    {
        printf("arg == %s\n", argv[1]);
        if (strcmp(argv[1], "X") == 0)
        {
            printf("disable exit on abnormal handler...\n");
            disable_exit = true;
        }
    }
    signal(SIGSEGV, AbnormalSignalHandler);
    give_me_an_error();
    return 0;
}

Output:

bowei.he:/sandbox/bowei.he/temp$ ./sigf
ABNORMAL SHUTDOWN!!!
bowei.he:/sandbox/bowei.he/temp$ ./sigf X
arg == X
disable exit on abnormal handler...
ABNORMAL SHUTDOWN!!!
Segmentation fault (core dumped)