免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1816 | 回复: 1

[Linux] linux下wcc使用_beginthread段错误 [复制链接]

论坛徽章:
0
发表于 2013-12-05 10:40 |显示全部楼层



#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <malloc.h>
#include <unistd.h>
#include <string.h>
#include <process.h>

void  child(void *args)
{
        printf("----------------------5\n");
        _endthread();
}


void main() {
        char *stack= NULL;
        int tid;
        void *child_pointer = child;
        printf("----------------------1\n");
        stack = (char *) malloc( 8192 );

        printf("----------------------3 stack:%p\n",stack);
        tid = _beginthread( child_pointer,  NULL, 0, NULL);
        sleep (1);
        printf("----------------------4\n");
        printf("Thread ID = %x\n", tid);

}

论坛徽章:
0
发表于 2013-12-05 10:41 |显示全部楼层
程序跟踪信息
7388  15:36:01.503157 execve("./watcom_thread", ["./watcom_thread"], [/* 57 vars */]) = 0 <0.000555>
7388  15:36:01.504034 brk(0)            = 0x82b2000 <0.000012>
7388  15:36:01.504118 brk(0x82b3000)    = 0x82b3000 <0.000014>
7388  15:36:01.504180 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 <0.000016>
7388  15:36:01.504264 write(1, "----------------------1\n", 24) = 24 <0.000018>
7388  15:36:01.504324 brk(0x82b5000)    = 0x82b5000 <0.000011>
7388  15:36:01.504381 write(1, "----------------------3 stack:082b2248\n", 39) = 39 <0.000012>
7388  15:36:01.504444 clone(child_stack=0x82b3248, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|SIGCHLD) = 7389 <0.000031>
7388  15:36:01.504518 write(1, "----------------------4\n", 24) = 24 <0.000012>
7388  15:36:01.504575 write(1, "Thread ID = 1cdd\n", 17) = 17 <0.000012>
7388  15:36:01.504703 _exit(17)         = ?
7389  15:36:01.504779 --- SIGSEGV (Segmentation fault) @ 0 (0) ---
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP