簡體   English   中英

OCaml Sys.command函數引發的“無子進程”錯誤

[英]“No child processes” error thrown by OCaml Sys.command function

我正在嘗試通過python應用程序使用Frama-c。 這個python應用程序設置了一些env變量和系統路徑。 在此應用程序中,我將Frama-c稱為python進程,如下所示:

cmd = ['/usr/local/bin/frama-c', '-wp', '-wp-print', '-wp-out', '/home/user/temp','/home/user/project/test.c']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)

從Python應用程序執行此代碼時,出現以下錯誤:

[kernel] Parsing FRAMAC_SHARE/libc/__fc_builtin_for_normalization.i (no preprocessing)
[kernel] warning: your preprocessor is not known to handle option ` -nostdinc'. If pre-processing fails because of it, please add -no-cpp-gnu-like option to Frama-C's command-line. If you do not want to see this warning again, use explicitely -cpp-gnu-like option.
[kernel] warning: your preprocessor is not known to handle option `-dD'. If pre-processing fails because of it, please add -no-cpp-gnu-like option to Frama-C's command-line. If you do not want to see this warning again, use explicitely -cpp-gnu-like option.
[kernel] Parsing 2675891095.c (with preprocessing)
[kernel] System error: /usr/bin/gcc -c -C -E -I.  -dD -nostdinc -D__FC_MACHDEP_X86_32 -I/usr/local/share/frama-c/libc -o '/tmp/2675891095.cc8bf16.i' '/home/user/project/test.c': No child processes

我發現很難調試導致錯誤的原因:

系統錯誤:/ usr / bin / gcc -c -C -E -I。 -dD -nostdinc -D__FC_MACHDEP_X86_32 -I / usr / local / share / frama-c / libc -o'/tmp/2675891095.cc8bf16.i''/home/user/project/test.c':沒有子進程

有沒有一種方法可以從Frama-c生成更多錯誤日志,這可能有助於我找出問題所在?

請注意,僅當我從應用程序啟動進程(以執行Frama-c)時才會發生此錯誤,如果從python控制台啟動它,則不會發生。 它僅在Linux計算機上發生,而不在Windows計算機上發生。

任何幫助表示贊賞。 謝謝!!

更新:我意識到通過使用-kernel-debug標志,我可以獲得堆棧跟蹤。 因此,我嘗試了該選項並獲得以下信息:

致命錯誤:異常Sys_error(“ gcc -E -C -I。-dD -D__FRAMAC__ -nostdinc -D__FC_MACHDEP_X86_32 -I / usr / local / share / frama-c / libc -o'/tmp/2884428408.c2da79b.i'' /home/usr/project/test.c':無子進程”)

通過原始操作在文件“ src / kernel_services / ast_queries / file.ml”處提高,第472行,字符9-32

從文件“ src / kernel_services / ast_queries / file.ml”中調用,第517行,字符14-26

從文件“ src / kernel_services / ast_queries / file.ml”中調用,行703,字符46-59

從文件“ list.ml”第84行調用,字符24-34

從文件“ src / kernel_services / ast_queries / file.ml”中調用,行703,字符17-76

從文件“ src / kernel_services / ast_queries / file.ml”中調用,行1587,字符24-47

從文件“ src / kernel_services / ast_queries / file.ml”中調用,行1667,字符4-27

從文件“ src / kernel_services / ast_data / ast.ml”中調用,第108行,字符2-28

從文件“ src / kernel_services / ast_data / ast.ml”中調用,第116行,字符53-71

從文件“ src / kernel_internals / runtime / boot.ml”中調用,第29行,字符6-20

從文件“ src / kernel_services / cmdline_parameters / cmdline.ml”中調用,行787,字符2-9

從文件“ src / kernel_services / cmdline_parameters / cmdline.ml”中調用,行817,字符18-64

從文件“ src / kernel_services / cmdline_parameters / cmdline.ml”中調用,第228行,字符4-8

在文件“ src / kernel_services / cmdline_parameters / cmdline.ml”處重新引發,第244行,字符12-15

從文件“ src / kernel_internals / runtime / boot.ml”中調用,第72行,字符2-127

我查看了文件"src/kernel_services/ast_queries/file.ml", line 472 ,執行的代碼是Sys.command cpp_command

我不確定為什么在嘗試執行execute gcc時會引發“無子進程”錯誤。

更新:我有Ocaml版本:4.02.3,Python版本:2.7.8和Frama-C版本:Silicon-20161101

我對Frama-C一無所知。 但是,錯誤消息來自某個人的(OCaml的還是Python的)運行時,表明系統調用因ECHILD錯誤而失敗。 system()進行的兩個系統調用是fork()waitpid() 后者是可以返回ECHILD系統調用。 這意味着沒有子進程可以等待。 一種很好的可能性是fork()失敗。 當系統充滿進程(不太可能)或達到每個用戶的進程限制時, fork()失敗。 您可以檢查是否遇到這種限制。

我想到的另一種可能性是,代碼的其他部分已經在使用信號處理( SIGCHLD )處理子進程。 因此,沒有等待子進程的原因是它已經在其他地方處理過。 這變得非常復雜,所以我希望這不是問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM