搞爆编译器的代码

来源:互联网 发布:php权威指南百度云 编辑:程序博客网 时间:2024/05/17 10:54

pascal:

C/C++:

 

fpc由于一直没把内存耗完,所以一直没停下来,倒是把系统弄得很慢。

g++把2G内存耗完后就爆了,耗时23s

 

运行着g++时:

$ free -m
             total       used       free     shared    buffers     cached
Mem:          2023       1975         48          0          1         14
-/+ buffers/cache:       1958         64
Swap:         4102        164       3937

 


$ time g++ test1.cpp

cc1plus: out of memory allocating 536870912 bytes after a total of 2060288 bytes

real    0m23.594s
user    0m12.542s
sys     0m3.652s


$ time fpc test.pas
Free Pascal Compiler version 2.2.4 [2009/03/28] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for i386
Compiling test.pas
Fatal: Compilation aborted


real    3m36.956s
user    0m0.000s
sys     0m0.034s

 

这些代码看似无聊,却对OJ系统的安全构成巨大威胁。。 看来要限制编译时间才行。

 

 

原创粉丝点击