简体   繁体   English

OCaml Sys.command函数引发的“无子进程”错误

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

I am trying to use Frama-c via python application. 我正在尝试通过python应用程序使用Frama-c。 This python application sets some env variables and system path. 这个python应用程序设置了一些env变量和系统路径。 From this application, I am calling Frama-c as a python process as following: 在此应用程序中,我将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)

When this code is executed from Python application I am getting following error: 从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

I am finding it hard to debug what is causing the error: 我发现很难调试导致错误的原因:

System error: /usr/bin/gcc -c -C -E -I. 系统错误:/ 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 -dD -nostdinc -D__FC_MACHDEP_X86_32 -I / usr / local / share / frama-c / libc -o'/tmp/2675891095.cc8bf16.i''/home/user/project/test.c':没有子进程

Is there a way to generate more error log from Frama-c that might help me figure out the issue? 有没有一种方法可以从Frama-c生成更多错误日志,这可能有助于我找出问题所在?

Note that this error only occur when I start the process(to execute Frama-c) from my application, and not if I start it from a python console. 请注意,仅当我从应用程序启动进程(以执行Frama-c)时才会发生此错误,如果从python控制台启动它,则不会发生。 And it happens only on Linux machine and not on Windows machine. 它仅在Linux计算机上发生,而不在Windows计算机上发生。

Any help is appreciated. 任何帮助表示赞赏。 Thanks!! 谢谢!!

Update : I realized that by using -kernel-debug flag I can obtain stack trace. 更新:我意识到通过使用-kernel-debug标志,我可以获得堆栈跟踪。 So I tried the option and get the following information: 因此,我尝试了该选项并获得以下信息:

Fatal error: exception 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': No child processes") 致命错误:异常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':无子进程”)

Raised by primitive operation at file "src/kernel_services/ast_queries/file.ml", line 472, characters 9-32 通过原始操作在文件“ src / kernel_services / ast_queries / file.ml”处提高,第472行,字符9-32

Called from file "src/kernel_services/ast_queries/file.ml", line 517, characters 14-26 从文件“ src / kernel_services / ast_queries / file.ml”中调用,第517行,字符14-26

Called from file "src/kernel_services/ast_queries/file.ml", line 703, characters 46-59 从文件“ src / kernel_services / ast_queries / file.ml”中调用,行703,字符46-59

Called from file "list.ml", line 84, characters 24-34 从文件“ list.ml”第84行调用,字符24-34

Called from file "src/kernel_services/ast_queries/file.ml", line 703, characters 17-76 从文件“ src / kernel_services / ast_queries / file.ml”中调用,行703,字符17-76

Called from file "src/kernel_services/ast_queries/file.ml", line 1587, characters 24-47 从文件“ src / kernel_services / ast_queries / file.ml”中调用,行1587,字符24-47

Called from file "src/kernel_services/ast_queries/file.ml", line 1667, characters 4-27 从文件“ src / kernel_services / ast_queries / file.ml”中调用,行1667,字符4-27

Called from file "src/kernel_services/ast_data/ast.ml", line 108, characters 2-28 从文件“ src / kernel_services / ast_data / ast.ml”中调用,第108行,字符2-28

Called from file "src/kernel_services/ast_data/ast.ml", line 116, characters 53-71 从文件“ src / kernel_services / ast_data / ast.ml”中调用,第116行,字符53-71

Called from file "src/kernel_internals/runtime/boot.ml", line 29, characters 6-20 从文件“ src / kernel_internals / runtime / boot.ml”中调用,第29行,字符6-20

Called from file "src/kernel_services/cmdline_parameters/cmdline.ml", line 787, characters 2-9 从文件“ src / kernel_services / cmdline_parameters / cmdline.ml”中调用,行787,字符2-9

Called from file "src/kernel_services/cmdline_parameters/cmdline.ml", line 817, characters 18-64 从文件“ src / kernel_services / cmdline_parameters / cmdline.ml”中调用,行817,字符18-64

Called from file "src/kernel_services/cmdline_parameters/cmdline.ml", line 228, characters 4-8 从文件“ src / kernel_services / cmdline_parameters / cmdline.ml”中调用,第228行,字符4-8

Re-raised at file "src/kernel_services/cmdline_parameters/cmdline.ml", line 244, characters 12-15 在文件“ src / kernel_services / cmdline_parameters / cmdline.ml”处重新引发,第244行,字符12-15

Called from file "src/kernel_internals/runtime/boot.ml", line 72, characters 2-127 从文件“ src / kernel_internals / runtime / boot.ml”中调用,第72行,字符2-127

And I looked at the file "src/kernel_services/ast_queries/file.ml", line 472 and the code executed is Sys.command cpp_command . 我查看了文件"src/kernel_services/ast_queries/file.ml", line 472 ,执行的代码是Sys.command cpp_command

I am not sure why "No Child Processes" error is thrown when trying to execute execute gcc. 我不确定为什么在尝试执行execute gcc时会引发“无子进程”错误。

Update: I have Ocaml version: 4.02.3, Python version: 2.7.8 and Frama-C version: Silicon-20161101 更新:我有Ocaml版本:4.02.3,Python版本:2.7.8和Frama-C版本:Silicon-20161101

I know nothing about Frama-C. 我对Frama-C一无所知。 However, the error message is coming from somebody's (OCaml's? Python's?) runtime, indicating that a system call failed with the ECHILD error. 但是,错误消息来自某个人的(OCaml的还是Python的)运行时,表明系统调用因ECHILD错误而失败。 The two system calls that system() makes are fork() and waitpid() . system()进行的两个系统调用是fork()waitpid() It's the latter system call that can return ECHILD . 后者是可以返回ECHILD系统调用。 What it means is that there's no child process to wait for. 这意味着没有子进程可以等待。 One good possibility is that the fork() failed. 一种很好的可能性是fork()失败。 fork() fails when the system is full of processes (unlikely) or when a per-user process limit has been reached. 当系统充满进程(不太可能)或达到每个用户的进程限制时, fork()失败。 You could check whether you're running up against a limit of this kind. 您可以检查是否遇到这种限制。

Another possibility that occurs to me is that some other part of the code is already handling child processes using signal handling ( SIGCHLD ). 我想到的另一种可能性是,代码的其他部分已经在使用信号处理( SIGCHLD )处理子进程。 So the reason there's no child process to wait for is that it has already been handled elsewhere. 因此,没有等待子进程的原因是它已经在其他地方处理过。 This gets complicated pretty fast, so I would hope this isn't the problem. 这变得非常复杂,所以我希望这不是问题。

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

相关问题 超时错误时杀死所有子进程但不杀死父进程 - Kill All Child Processes But Not The Parent Processes Upon Timeout Error 子进程的生成器函数在父进程中运行 - Generator function of child processes runs in the Parent process Django 1.5管理命令-IOError:[Errno 10]-没有子进程 - Django 1.5 Management Command - IOError: [Errno 10] - No child processes 在 python 中使用solve() function 引发异常错误 - Exception Thrown error using solve() function in python 使用子进程python获取命令行执行抛出的错误 - Get error thrown by command-line execution using subprocess python 如何使正在运行的函数及其所有子进程在Linux上超时? - How to timeout a running function and all it's child processes on Linux? 在 function 中使用 sys.argv 作为参数的语法错误 - Syntax error using sys.argv as argument in function 为什么 exec 命令在运行以下代码时会抛出错误? - Why does exec command thrown an error on running the following code? “sys$stdout$flush() 中的错误:尝试应用非函数” - “Error in sys$stdout$flush() : attempt to apply non-function” gyp ERR:堆栈错误:命令失败; python -c 导入系统。 打印 "%s.%s.%s" % sys:version_info[:3] - gyp ERR! stack Error: Command failed: python -c import sys; print "%s.%s.%s" % sys.version_info[:3]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM