yyzybb537 / libgo

Go-style concurrency in C++11
MIT License
3.22k stars 758 forks source link

这个代码有问题?会报告段错误. #176

Closed wkexinw closed 5 years ago

wkexinw commented 5 years ago

`#include

include <libgo/coroutine.h>

using namespace std;

co_chan ch_0;

void test(){ int r=0; for(;;){ ch_0 >> r; } }

void test2(){ int i=0; ch_0 << i; i++; }

int main(int argc, char** argv) { co_chan ch_1;

go [=]{
    ch_1 <<1;
};

go [=]{
    int r=0;
    ch_1 >> r;

    printf("%d\n",r);
};
//go test2;
//go test;
co_sched.Start();

thread([]{ co_sleep(2000); co_sched.Stop(); }).detach();
return 0;

}` compile with : g++ -std=c++11 test.cpp -I /opt/libgo/include/ -L /opt/libgo/lib -llibgo -lpthread

错误: (gdb) r Starting program: /home/goemon/gat-1400/src/a.out [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff698f700 (LWP 8688)]

Thread 1 "a.out" received signal SIGSEGV, Segmentation fault. 0x00007ffff7ba6276 in jump_fcontext () from /home/goemon/gat-1400/lib/liblibgo.so

yyzybb537 commented 5 years ago

rm /home/goemon/gat-1400/lib/liblibgo.so 旧版的so删了就好了