From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ar.aichi-u.ac.jp ([202.250.160.40]) by ttr; Sun May 4 01:24:25 EDT 2014 Received: from [10.63.0.29] ([10.63.0.29]) by ar; Sun May 4 14:24:14 JST 2014 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: malloc From: Kenji Arisawa In-Reply-To: Date: Sun, 4 May 2014 14:24:14 +0900 Content-Transfer-Encoding: 7bit Message-Id: <94FC2DC4-E47A-4B93-80B4-F0B3F8E98E04@ar.aichi-u.ac.jp> List-ID: <9front.9front.org> X-Glyph: ➈ X-Bullshit: abstract RESTful package callback hypervisor-based layer References: <3B54C219-B268-4BAA-9638-62CEF6E18EDB@ar.aichi-u.ac.jp> To: 9front@9front.org X-Mailer: Apple Mail (2.1510) It seems malloc() has a problem with large size allocation. void test1(void) { char *p, buf[256]; ulong i,n[16]; ulong MB = 1024*1024; n[0] = 1024; n[1] = 1024; n[2] = 1024; n[3] = 512; n[4] = 0; for(i = 0; n[i]; i++){ p = malloc(n[i]*MB); print("%d %uldMB %08p\n",i,n[i],p); if(p ==nil) continue; } read(0,buf, sizeof(buf)); } term% 6.out 0 1024MB 00401948 1 1024MB 404019b0 2 1024MB 80401a18 3 512MB c0401a80 # this is OK void test2(void) { char *p, buf[256]; ulong i,n[16]; ulong MB = 1024*1024; n[0] = 3*1024+512; n[1] = 0; for(i = 0; n[i]; i++){ p = malloc(n[i]*MB); print("%d %uldMB %08p\n",i,n[i],p); if(p ==nil) continue; } read(0,buf, sizeof(buf)); } term% 6.out 0 3584MB 00000000 # this is NG