4

Getting a strange error on my Crouton chroot on my Chromebook after apt-get install smlnj and attempting to call sml from the terminal, an error that I haven't been able to find anywhere else:

$ sml
/usr/lib/smlnj/bin/sml: Error -- unable to map 1179648 bytes, errno = 1
/usr/lib/smlnj/bin/sml: Fatal error -- unable to allocate memory object for BIBOP

Any guidance?

jayelm
  • 7,236
  • 5
  • 43
  • 61
  • What a system is it and what does `free -m` show? – barti_ddu May 19 '14 at 17:27
  • @barti_ddu I'm running Xubuntu in a chroot on a chromebook with just 2GB of memory. At any given time there's around 100 - 500 MB free. Is this prohibitive to sml? – jayelm May 23 '14 at 22:25
  • AFAIR, 32MB should be enough for small scripts; however it seems that os is refusing sml's process to allocate even this amount of memory. Have you tried to increase/turn on swap temporarily? – barti_ddu May 28 '14 at 14:38
  • Yeah, ~2GB swap is currently enabled on my system. Any ideas why the os could be refusing this? – jayelm May 30 '14 at 20:21
  • Hmm, can you try to run sml/nj as follows: `sml @SMLalloc=128k` (or even smaller alloc size, say, 64/32/16/8k)? `run-sml` script may just do incorrect guess for your (celeron?) CPU. – barti_ddu May 31 '14 at 20:23
  • I'm only able to set @SMLalloc to 128k before it says the option is too small. Unfortunately, I still get the same error, just with `unable to map n bytes` reduced. – jayelm Jun 01 '14 at 04:34

1 Answers1

4

Edit: This issue (bug #120) was fixed in SML/NJ version 110.77 (release notes) by enabling MAP_ANONYMOUS, which was previously unsupported in Linux. Installing the latest version of SMLNJ would be preferable to the solution below, since it doesn't require weakening the security of the system. If you do continue via modifying the permissions of /dev, it's advisable to remove exec permission after each session.


This problem is primarily reproducible in a Chromium OS environment running ChrUbuntu or Crouton, but may happen to other users in other environments who have a similar problem.

Running strace on sml gives this (attempted) operation before the error output:

open("/dev/zero", O_RDONLY)             = 4
mmap2(NULL, 1245184, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 4, 0) = -1 EPERM (Operation not permitted)

According to the mmap(2) documentation, EPERM indicates that the system is attempting to allocate memory with execute permission in a directory that is marked noexec.

Indeed, mount gives:

...
devtmpfs on /dev type devtmpfs (rw,nosuid,noexec,relatime,size=960456k,nr_inodes=240114,mode=755)
...

The solution is thus to remount /dev with exec permission:

$ sudo mount -o remount,exec /dev
$ sml
Standard ML of New Jersey v110.75 [built: Thu May  9 05:41:01 2013]
- 
jayelm
  • 7,236
  • 5
  • 43
  • 61