Sunghyun Park via llvm-dev
2017-Aug-01 15:22 UTC
[llvm-dev] [HELP] Segfault on printing out structure elements
Hi, all. I'm a graduate student working on creating llvm pass that generates resilient version of code automatically. Basically, what it does is to duplicate instructions and compare them at the synchronization points, such as function call, branch. Plus, there is one more copy for recovery. So if two copies agree, program will proceed with original copy, or otherwise it will use the third copy as corrected one. It looks like below. e.g. $inst1 = add $1, $2 $inst2 = add $3, $4 $inst3 = add $5, $6 $cmp = icmp $inst1, $inst2 $corrected = sel $cmp, $inst1, $inst3 printf $corrected //very simplified form Everything was going fine, but now I'm stuck at a weird bug that I cannot quite understand. If the instructions to be copied are accessing structure elements and they are printed out by printf or fprintf(like example above except it does not access structure), it occurs segfault at runtime even though they are legit memory access. * Here's more clarification for my situation. - It compiles successfully. - If I commented out 'printf' or 'fprintf' from the source code, the program works fine. So it seems like there's a problem on this part. - For other printf with corrected value, they works fine if they are not accessing structure element. Error msg and comparison between original code and transformed code by my pass are attached below. I tried to make it shown here but the size wasn't fit. Is there anyone who had same problem or have any idea/guess/hint for me? Thank you in advance! -- Best, Sung -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170801/e5baa589/attachment-0001.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: cfgs.png Type: image/png Size: 208458 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170801/e5baa589/attachment-0001.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: error_msg Type: application/octet-stream Size: 211586 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170801/e5baa589/attachment-0001.obj>
陳韋任 via llvm-dev
2017-Aug-02 22:39 UTC
[llvm-dev] [HELP] Segfault on printing out structure elements
Perhaps you can run verify [1] after your transformation to do sanity check. [1] http://llvm.org/docs/doxygen/Verifier_8h_source.html Regards, chenwj 2017-08-01 23:22 GMT+08:00 Sunghyun Park via llvm-dev <llvm-dev at lists.llvm.org>:> Hi, all. > I'm a graduate student working on creating llvm pass that generates > resilient version of code automatically. > Basically, what it does is to duplicate instructions and compare them at the > synchronization points, such as function call, branch. Plus, there is one > more copy for recovery. So if two copies agree, program will proceed with > original copy, or otherwise it will use the third copy as corrected one. It > looks like below. > e.g. > $inst1 = add $1, $2 > $inst2 = add $3, $4 > $inst3 = add $5, $6 > $cmp = icmp $inst1, $inst2 > $corrected = sel $cmp, $inst1, $inst3 > printf $corrected //very simplified form > > Everything was going fine, but now I'm stuck at a weird bug that I cannot > quite understand. > If the instructions to be copied are accessing structure elements and they > are printed out by printf or fprintf(like example above except it does not > access structure), it occurs segfault at runtime even though they are legit > memory access. > > * Here's more clarification for my situation. > - It compiles successfully. > - If I commented out 'printf' or 'fprintf' from the source code, the program > works fine. So it seems like there's a problem on this part. > - For other printf with corrected value, they works fine if they are not > accessing structure element. > > > Error msg and comparison between original code and transformed code by my > pass are attached below. I tried to make it shown here but the size wasn't > fit. > > Is there anyone who had same problem or have any idea/guess/hint for me? > Thank you in advance! > > > -- > Best, Sung > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- Wei-Ren Chen (陳韋任) Homepage: https://people.cs.nctu.edu.tw/~chenwj