linux中获取SIGSEGV的上下文
context in linux getting SIGSEGV
我对用户定义线程的上下文内容很陌生。我写了一个关于上下文的简单程序。。。但它给了我分段错误。。。
#include<iostream>
#include<ucontext.h>
#include<stdlib.h>
using namespace std;
void fun1()
{
cout<<"from 1";
}
void fun2()
{
cout<<"from 2";
}
int main()
{
ucontext_t a,b;
cout<<"y";
getcontext(&b);
b.uc_link=0;
b.uc_stack.ss_sp=malloc(32767);
b.uc_stack.ss_size=32767;
b.uc_stack.ss_flags=0;
makecontext(&b, fun1, 0);
getcontext(&a);
a.uc_link=&b;
a.uc_stack.ss_sp=malloc(32767);
a.uc_stack.ss_flags=0;
makecontext(&a, fun2, 0);
setcontext(&a);
return 0;
}
`
I want to know how to allocate memory using
新的而不是malloc??有什么想法吗??
您忘记了:
a.uc_stack.ss_size=32767;
相关文章:
- #为""定义宏;静态";针对不同的上下文
- 与互斥锁相比,旋转锁可以保证上下文切换
- 线程,如果else语句,都是错误的上下文切换后,会发生什么
- 为什么我不能使用 EGL 创建无头 OpenGl 上下文?
- 创建LinkedList退出,返回代码为-11(SIGSEGV)
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 为什么在逗号分隔符上下文中将预增量的结果强制转换为void
- 错误"Could not find Boost"(缺少:上下文标头)
- 使用 mod_gsoap 部署服务时,如何在 Gsoap 中更改 soap 上下文的模式?
- SIGSEGV 使用shared_ptr引用时
- 将有状态的 lambda 传递到 C 样式函数中,而无需上下文参数
- SIGSEGV, 分段错误. 而 printf() 数组索引的值
- SIGSEGV on Boost UDP 套接字关闭 - tcache_get at malloc.c.
- 安排带有上下文的协同程序
- 我的文件无法正常工作,无法从C++文件中读取上下文
- 分段故障 运行C++代码时出现 SIGSEGV
- DCMTK 了解"DIMSE 没有有效的演示上下文 ID"错误
- 具有std::initializer_list参数的非成员函数(/non构造函数上下文)的重载解析
- antlr 规则上下文是否可以独立于目标
- linux中获取SIGSEGV的上下文