简体   繁体   English

C-当调用sigqueue时,Valgrind报告“ Syscall参数指向未初始化的字节”

[英]C - Valgrind reporting “Syscall param points to uninitialised byte” when sigqueue call

Got a program where child processes need to send father some signals. 得到了一个程序,其中子进程需要向父亲发送一些信号。 Yet, valgrind yells at sigqueue call. 然而,瓦尔格朗德在电话会议上大喊大叫。 Been reading for a time now but I couldn't find an answer. 现在已经阅读了一段时间,但我找不到答案。

Here's what child process do: 这是子进程的作用:

void cajero(int id){
    FILE *fp, *fp_caja;
    char filename[MAXBUFF], filename_caja[MAXBUFF], price[8];
    float p;
    union sigval val;
    bool booleano;

    ...

    val.sival_int = id;

    while(fgets(price, sizeof(price), fp)){
        p = atof(price);

        ...

        sigqueue(getppid(), SIGMONEY, val); //sigqueue Call

    }
    ...

    sigqueue(getppid(), SIGDONE, val); //sigqueue Call
    fclose(fp);
    exit(EXIT_SUCCESS);
}

And here's valgrind report for one child (it makes two calls in the inner sigqueue and one call in the outer: 这是一个孩子的valgrind报告(它在内部sigqueue中进行两次调用,在外部sigqueue中进行一次调用:

==14688== HEAP SUMMARY:
==14688==     in use at exit: 0 bytes in 0 blocks
==14688==   total heap usage: 48 allocs, 48 frees, 107,460 bytes allocated
==14688== 
==14688== All heap blocks were freed -- no leaks are possible
==14688== 
==14688== ERROR SUMMARY: 3 errors from 2 contexts (suppressed: 0 from 0)
==14688== 
==14688== 1 errors in context 1 of 2:
==14688== Syscall param rt_sigqueueinfo(uinfo) points to uninitialised byte(s)
==14688==    at 0x508DBE4: sigqueue (sigqueue.c:43)
==14688==    by 0x401B3A: cajero (ejercicio9.c:316)
==14688==    by 0x40130C: main (ejercicio9.c:181)
==14688==  Address 0xffefff67c is on thread 1's stack
==14688==  in frame #0, created by sigqueue (sigqueue.c:30)
==14688==  Uninitialised value was created by a stack allocation
==14688==    at 0x4018D7: cajero (ejercicio9.c:284)
==14688== 
==14688== 
==14688== 2 errors in context 2 of 2:
==14688== Syscall param rt_sigqueueinfo(uinfo) points to uninitialised byte(s)
==14688==    at 0x508DBE4: sigqueue (sigqueue.c:43)
==14688==    by 0x401AC1: cajero (ejercicio9.c:311)
==14688==    by 0x40130C: main (ejercicio9.c:181)
==14688==  Address 0xffefff67c is on thread 1's stack
==14688==  in frame #0, created by sigqueue (sigqueue.c:30)
==14688==  Uninitialised value was created by a stack allocation
==14688==    at 0x4018D7: cajero (ejercicio9.c:284)
==14688== 
==14688== ERROR SUMMARY: 3 errors from 2 contexts (suppressed: 0 from 0)

Thanks in advance. 提前致谢。 I'm braindead right now. 我现在快死了。

EDIT: SIGMONEY and SIGDONE are SIGRTMIN and SIGRTMIN+1 respectively. 编辑:SIGMONEY和SIGDONE分别是SIGRTMIN和SIGRTMIN + 1。

You're not initializing the "val" union. 您没有初始化“ val”联合。 Just change the declaration: 只需更改声明:

union sigval val = {0};

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用fwrite将结构写入文件时,Valgrind错误-Syscall参数写入(buf)指向未初始化的字节 - Valgrind error when writing struct to file with fwrite - Syscall param write(buf) points to uninitialised byte(s) Syscall参数msgsnd(msgp-> mtext)指向未初始化的字节-消息队列-Valgrind - Syscall param msgsnd(msgp->mtext) points to uninitialised byte(s) - Message queues - Valgrind Valgrind奇怪的“Syscall param socketcall.sendto(msg)指向未初始化的字节” - Valgrind strange “Syscall param socketcall.sendto(msg) points to uninitialised byte(s)” Valgrind macOs和错误Syscall param msg-> desc.port.name指向未初始化的字节 - Valgrind macOs and error Syscall param msg->desc.port.name points to uninitialised byte(s) Silence valgrind param write(buf) 指向未初始化的字节 - Silence valgrind param write(buf) points to uninitialised byte(s) 在Valgrind中获取“Syscall param execve(argv)指向不可寻址的字节” - Getting “Syscall param execve(argv) points to unaddressable byte(s)” in valgrind “Syscall param open(mode)在开放的sys调用中包含未初始化的字节” - “Syscall param open(mode) contains uninitialised byte(s)” in open sys call read()失败,地址错误,valgrind显示Syscall param read(buf)指向不可寻址的字节 - read() fails with Bad address, valgrind shows Syscall param read(buf) points to unaddressable byte(s) linux stat参数指向未初始化的字节? - c linux stat param points to uninitialised bytes? 为什么valgrind报告未初始化的值错误? - Why is valgrind reporting an uninitialised value error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM