Java堂  


windows版本的php5.2.3的一个bug

归档在: DynamicLanguage — Jet @ 10:47 下午
Tags: , ,
原文出处: http://www.javatang.com/archives/2007/06/20/4711201.html
作者: Jet Mah from Java堂
声明: 可以非商业性任意转载, 转载时请务必以超链接形式标明文章原始出处、作者信息及此声明!

PHP5.2.3-win32这个版本有个非常严重的bug,那就是最大内存设置成1024M,但是PHP实际返回的只有2M,经常返回下面的错误:

PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 786432) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 1310720) (tried to allocate 393216 bytes)

这是官方的bug报告,该bug只出现于windows版本,linux版本没有这个bug。看来只能等下一次升级的时候修复了。

遇到一个JDK5.0 Update7 以前的bug

归档在: JavaPlateform — Jet @ 4:44 下午
Tags: ,
原文出处: http://www.javatang.com/archives/2006/10/10/444472.html
作者: Jet Mah from Java堂
声明: 可以非商业性任意转载, 转载时请务必以超链接形式标明文章原始出处、作者信息及此声明!

一直都使用的是JDK5.0 Update6这个版本,中间也懒得升级。最近在程序的日志里面发现很多这样一个Exception:

java.lang.IllegalArgumentException
at sun.net.www.ParseUtil.decode(ParseUtil.java:179)
at sun.net.www.ParseUtil.toURI(ParseUtil.java:253)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:738)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:669)

查了下JDK,IllegalArgumentException是由于参数传递错误而产生的,但是查遍了程序并没有发现这个错误。于是Google了一下,竟然在sun的官方bug站上发现了,原来是一个bug。比如以下代码如果运行在JDK5.0 Update7以前的版本中就会产生上面的 IllegalArgumentException。

  1. class Bug { 
  2.     public static void main(String[] args) throws Exception { 
  3.         // 如果网址中出现 % 就会产生 IllegalArgumentException
  4.         java.net.URL url = new java.net.URL("http://www.example.com/%93%fa/");
  5.         java.net.URLConnection uc = url.openConnection();
  6.         uc.connect();
  7.     } 
  8. }

这个bug存在于JDK5.0 Update7以前的版本,于是下载了最新的JDK重新运行就没有错误了。

参考资料:
Bug ID: 6274990 REGRESSION: URLConnection.connect() throws Exception with non UTF-8 char
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6274990