Code Monkey home page Code Monkey logo

Comments (4)

zhengshuxin avatar zhengshuxin commented on June 3, 2024

照着你的例子测试了一下,我的环境没有发现问题,而且和O3也没有关系。你可以先测试一下 lib_acl_cpp/samples/redis/redis_set 看看是否有问题。另外,你用 pthread_attr_getstacksize 检查一下的运行栈大小是多少.

from acl.

qazwsxedckll avatar qazwsxedckll commented on June 3, 2024

栈大小,140721235895024

[root@665f6d9e8582 redis_set]# ./redis_set -a all
sadd ok, key: set_key_0, ret: 1000
scard ok, key: set_key_0, count: 1000
Segmentation fault
[root@665f6d9e8582 redis_list]# ./redis_list -a lrange
Segmentation fault (core dumped)

#0  acl::redis_result::put (this=this@entry=0x22d566c, rr=0x22da438, idx=idx@entry=79)
    at src/redis/redis_result.cpp:246
#1  0x0000000000436425 in acl::redis_client::get_array (this=this@entry=0x7ffcad2aac40, conn=..., 
    dbuf=dbuf@entry=0x22d5628) at src/redis/redis_client.cpp:327
#2  0x000000000043626e in acl::redis_client::get_object (this=this@entry=0x7ffcad2aac40, conn=..., 
    dbuf=dbuf@entry=0x22d5628) at src/redis/redis_client.cpp:353
#3  0x00000000004366dd in acl::redis_client::run (this=0x7ffcad2aac40, dbuf=0x22d5628, req=..., 
    nchildren=nchildren@entry=0, rw_timeout=rw_timeout@entry=0x0) at src/redis/redis_client.cpp:416
#4  0x000000000043ad25 in acl::redis_command::run (this=this@entry=0x7ffcad2aace8, nchild=nchild@entry=0, 
    timeout=timeout@entry=0x0) at src/redis/redis_command.cpp:398
#5  0x000000000043dc90 in acl::redis_command::get_strings (this=this@entry=0x7ffcad2aace8, 
    out=out@entry=0x7ffcad2aa580) at src/redis/redis_command.cpp:599
#6  0x0000000000438512 in acl::redis_list::lrange (this=this@entry=0x7ffcad2aace0, key=key@entry=0x49d932 "list", 
    start=start@entry=0, end=end@entry=1000, result=result@entry=0x7ffcad2aa580) at src/redis/redis_list.cpp:521
#7  0x00000000004298df in test_lrange (redis=...) at redis_list.cpp:427
#8  main (argc=<optimized out>, argv=<optimized out>) at redis_list.cpp:794

lrange也是有问题的,跟 #236 是一样的,会挂在idx=79

又试了一下,确实跟O3优化没关系,但是,只要加上打印printf("%ld\n", i);就正常,或者加上i=i;,不加就会崩溃。没什么思路了。

我看了一下,别的相同的issue,用的都是ubuntu18.04,自带的gcc为7.3.x。根据 #206 ,我这里也是7.3.1会挂,9.4.0没有问题,也许是gcc的bug?

from acl.

qazwsxedckll avatar qazwsxedckll commented on June 3, 2024

应该确定为gcc7.3.x的O3优化问题了

Breakpoint 1, acl::redis_result::put (this=this@entry=0x18bfad8, rr=0x18bff20, idx=idx@entry=9) at src/redis/redis_result.cpp:244
244             for (size_t i = 0; i < children_idx_; i++) {
Missing separate debuginfos, use: debuginfo-install libgcc-4.8.5-44.el7.x86_64 libstdc++-4.8.5-44.el7.x86_64 zlib-1.2.7-20.el7_9.x86_64
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$1 = 0
(gdb) n
244             for (size_t i = 0; i < children_idx_; i++) {
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$2 = 0
(gdb) n
244             for (size_t i = 0; i < children_idx_; i++) {
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$3 = 1

首先是在entry=9时,for循环会有2次i=0

Breakpoint 1, acl::redis_result::put (this=this@entry=0x12cead8, rr=0x12cfd38, idx=idx@entry=39) at src/redis/redis_result.cpp:244
244             for (size_t i = 0; i < children_idx_; i++) {
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$1 = 0
(gdb) n
244             for (size_t i = 0; i < children_idx_; i++) {
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$2 = 0
(gdb) n
244             for (size_t i = 0; i < children_idx_; i++) {
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$3 = 0
(gdb) n
244             for (size_t i = 0; i < children_idx_; i++) {
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$4 = <optimized out>
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
acl::redis_result::put (this=this@entry=0x12cead8, rr=0x12cfd38, idx=idx@entry=39) at src/redis/redis_result.cpp:245
245                     children[i] = children_[i];

然后在entry=39时,for循环i=0会进3次,第四次被优化掉,然后就挂了。

Breakpoint 1, acl::redis_result::put (this=this@entry=0xc04ad8, rr=0xc05d38, idx=idx@entry=39) at src/redis/redis_result.cpp:244
244             for (size_t i = 0; i < children_idx_; i++) {
(gdb) p i
$4 = 0
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$5 = 0
(gdb) n
244             for (size_t i = 0; i < children_idx_; i++) {
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$6 = 0
(gdb) n
244             for (size_t i = 0; i < children_idx_; i++) {
(gdb) n
245                     children[i] = children_[i];
(gdb) p i
$7 = 1

这是O2的情况,i的值没有被优化掉,但是也进了2次0,暂时先不看这个问题了。

from acl.

zhengshuxin avatar zhengshuxin commented on June 3, 2024

嗯,我在自己的环境中确实无法复现你所说的问题。

from acl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.