PHPããã°ã©ã ãæ¸ããããã¤ãã¹21åè¡ç®ãããã§ã¨ã©ã¼ãåºã
ï¼2016/10/5 20:40 追è¨ï¼èª¤è§£ãæãã¦ããé¨åããããããªã®ã§ææ«ã«è£è¶³ã追è¨ãã¾ããã巨大ãªããã°ã©ã ãé£ãããã ãã§PHPãæ»ã¬ããã§ã¯ããã¾ããã
æ¯åº¦ããªãã¿ãæå³çã«éç®±ã®é ãã¤ã¤ãã¦ã¿ããã£ã¦è©±ã§ããããPHPããã°ã©ã ãå®è¡ããã次ã®ãããªã¨ã©ã¼ã«ééãã¾ããã
$ php over-2g-lines.php int(0) PHP Fatal error: Uncaught Error: Call to undefined function var____dump() in /Users/hnw/over-2g-lines.php:2150000004 Stack trace: #0 {main} thrown in /Users/hnw/over-2g-lines.php on line -2144967292
21å5åä¸4è¡ç®ã§è´å½çã¨ã©ã¼ãçºçãããï¼ã¨ãã表示ã®ãã¨ã§ã¹ã¿ãã¯ãã¬ã¼ã¹ã表示ããã¦ãããã§ãããã¹ã¿ãã¯ãã¬ã¼ã¹ã®æ¹ã§ã¯ãã¤ãã¹21.4åè¡ç®ãããã§ã¨ã©ã¼ãåºã¦ãããã¨ã«ãªã£ã¦ãã¾ããè¡æ°ããã¤ãã¹ã¨ããã®ã¯ä¸æè°ã§ããã
種æããããã¾ã§ããªãã¨æãã¾ãããåå ã¯32bitæ´æ°ã®ãªã¼ãã¼ããã¼ã§ããPHPã®VMå½ä»¤ã管çããzend_opæ§é ä½ã®linenoã¡ã³ãã¯32bit符å·ç¡ãæ´æ°ã§ç®¡çããã¦ãããããPHPã¯43åè¡ç®ãããã¾ã§ããæ£ç¢ºã«ããã°ã©ã ã®è¡æ°ãã«ã¦ã³ãã§ãã¾ããã
ããã«ãprintfã®ä¿®é£¾åã¨ãã¦%dãªã©ã¨signedã®æå®ããã¦ããå ´æãããã¨ä¸ã®ããã«21.5åãããã§ãªã¼ãã¼ããã¼ãã¦è² æ°ã«ãªã£ã¦ãã¾ãã¾ããããã¯ãã¡ãããã°ã§ãããä¿®æ£ããã¨ããã§èª°å¾ãªæ°ããã¾ããæ°ãåããããã°ã¬ããåºããããªã¨æãã¤ã¤ãä»æ¥ã¯ããã°è¨äºã«ãã¦å¯ããã¨ã«ãã¾ãã
ã¡ãªã¿ã«ä¸è¨çµæã¯PHP 7.0.9ã®ãã®ã§ãããPHP 5ç³»ï¼5.3.0以éï¼ã§ã大差ãªãã¨ã©ã¼è¡¨ç¤ºã«ãªãã¾ãã
åç¾æ¹æ³
æå ã§ãåç¾ãããæ¹ã®ããã«ãå®é¨ã«ä½¿ã£ãPHPããã°ã©ã ãgistã«ä¸ãã¦ããã¾ããã次ã®ããã«ããã°å ã®ããã°ã©ã ãæå ã«å¾©å ã§ãã¾ãã
$ curl 'https://gist.githubusercontent.com/hnw/128439edf806daadbdf548b730d67627/raw/over-2g-lines.php.bz2.base64' | base64 -D | bzip2 -cd > over-2g-lines.php
gistã«ä¸ãã£ã¦ãããã¡ã¤ã«ã¯2KBã»ã©ã§ãããå±éå¾ã®PHPãã¡ã¤ã«ã¯ç´2GBã«ãªãã¾ãã®ã§ãããã¹ãã¨ãã£ã¿ãªã©ã§éãã¨ç¢ºå®ã«å¤§æ¨äºã§ããã注æãã ããã
ã¡ãªã¿ã«PHPãã¡ã¤ã«ã®å 容ã¯ä»¥ä¸ã®éãã§ãã
<?php /* ï¼21å5åä¸è¡ã®ç©ºè¡ï¼ */ $x=0; var_dump($x); var____dump($x);
è£è¶³ã¨ãããè足ã¨ããã
21.5åè¡ãè¶ ããPHPããã°ã©ã ãåããã¨PHPãã¨ã©ã¼ãè¿ãããã«èªã¿åã£ãæ¹ãããããããã¾ããããããã§ã¯ããã¾ããã巨大ãªããã°ã©ã ã®å¾ãã®æ¹ã§ããã¨ã¨ã©ã¼ãåºãã¦ã¿ããã¨ããã®ãä¸ã®å®é¨å 容ã§ããå®éã21å5åä¸3è¡ç®ã®var_dump($x)ã®çµæã¯æ£ããåºåããã¦ãã¾ãï¼æåã®å®è¡çµæãåç §ãã ããï¼ã21.5åè¡ç®ãã43åè¡ç®ã®éãããã§ã¨ã©ã¼ãèµ·ãããå ´åã«ã¨ã©ã¼è¡¨ç¤ºç®æã®è¡æ°è¡¨ç¤ºããã¤ãã¹ã«ãªããã°ãããã¿ãããã¨ããã®ããä¼ããããã£ãå 容ã§ããã
ãããããå¤ä»£ã®BASIC以å¤ã®ããã°ã©ãã³ã°è¨èªã«ã¨ã£ã¦è¡æ°ã¨ããã®ã¯éè¦ãªãã©ã¡ã¼ã¿ã§ã¯ãªããã¨ã©ã¼çºçæã«çºçç®æããããããã表示ããããã®è£å©æ å ±ã«éãã¾ãããããã¯PHPã«ããã¦ãåãã§ãã©ãã ãè¡æ°ã®å¤ãããã°ã©ã ãä¸ãã¦ãããã ãã§æ»ã¬ãã¨ã¯ããã¾ããã
ãã£ã¨ããããã¢ãªå¦çã21åè¡æ¸ãããããã°ã©ã ãä¸ããã¨ããã°ã©ã ã®parseã ãã§å¤§éã®CPUæéã¨ã¡ã¢ãªãæ¶è²»ãã¦ãã¾ããå¥ã®çç±ã§æ»ã¬å¯è½æ§ãé«ãã¨æãã¾ããããã¯ä»ã®è¨èªã§ãåãã§ãããã