Opened 3 years ago

Closed 11 months ago

#1218 closed defect (fixed)

chicken-install may fail if TMPDIR is mounted noexec (depending on setup-file details)

Reported by: iraikov Owned by:
Priority: major Milestone: 5.0
Component: extensions Version: 4.10.x
Keywords: coops Cc:
Estimated difficulty: hard

Description

chicken-install coops results in the following error:

installing coops:1.93 ...
changing current directory to /tmp/temp4661.6142/coops

'/home/igr/bin/chicken/bin/csi' -bnq -setup-mode -e "(require-library setup-api)" -e "(import setup-api)" -e "(setup-error-handling)" -e "(extension-name-and-version '(\"coops\" \"1.93\"))" 'coops.setup'
'/home/igr/bin/chicken/bin/csc' -feature compiling-extension -setup-mode -s -O3 -d1 coops-module.scm -JS -o coops.so
'/home/igr/bin/chicken/bin/csc' -feature compiling-extension -setup-mode -s -O3 -d0 coops.import.scm
'/home/igr/bin/chicken/bin/csc' -feature compiling-extension -setup-mode -s -O3 -d1 coops-primitive-objects -JS

Error: (load) during expansion of (import ...) - unable to load compiled module - ./coops.import.so: failed to map segment from shared object: Operation not permitted: "./coops.import.so"

Change History (13)

comment:1 follow-ups: Changed 3 years ago by evhan

Unable to replicate on Linux or OpenBSD. On what platform did this occur?

comment:2 in reply to: ↑ 1 Changed 3 years ago by iraikov

Ubuntu Linux 14.04 / gcc 4.8.4

Replying to evhan:

Unable to replicate on Linux or OpenBSD. On what platform did this occur?

comment:3 in reply to: ↑ 1 Changed 3 years ago by iraikov

One more thing, did you try a fresh CHICKEN installation, or did you already have coops installed?

Replying to evhan:

Unable to replicate on Linux or OpenBSD. On what platform did this occur?

comment:4 follow-up: Changed 3 years ago by sjamaan

This sounds like a noexec mount of /tmp.

I don't know whether that's fixable (I don't know much about coops and its installation procedure), but this causes trouble with several other eggs, IIRC. So perhaps it's not really a coops bug (though one could argue it's a bug in chicken-install, if a very difficult one to fix)

comment:5 in reply to: ↑ 4 Changed 3 years ago by iraikov

True, /tmp is mounted noexec on this system. I remember now that I ran into this issue with an unrelated piece of software a few weeks ago.

I was able to find a workaround by changing the first line in coops.setup

(compile -s -O3 -d1 coops-module.scm -JS -o coops.so)

to

(compile -s -O3 -d1 coops.scm -JS)

And switching around the files coops-module.scm and coops.scm so that now coops.scm includes coops-module.scm.

Is it the -o option to chicken-install that does not work with noexec-mounted /tmp? If so, I will re-title this issue accordingly.

Replying to sjamaan:

This sounds like a noexec mount of /tmp.

I don't know whether that's fixable (I don't know much about coops and its installation procedure), but this causes trouble with several other eggs, IIRC. So perhaps it's not really a coops bug (though one could argue it's a bug in chicken-install, if a very difficult one to fix)

comment:6 Changed 3 years ago by sjamaan

I tried to reproduce what you said you did to the files, but I keep getting the same error message.

However, it worked if I simply moved the import files to the end (even with the orignal versions of coops.scm and coops-module.scm), so they're compiled after all the other files. That's because the (import foo) statements will then fall back to simply loading the source files instead. This may be a good "solution" for coops and similar eggs (perhaps 90% of our eggs, in fact), but it won't work in the general case:

If you have an egg consisting of two modules, let's say module A and B, where A depends on B at compile-time (perhaps B offers some important macros), it must be able to load it. If module B contains FFI calls, it must be compiled.

Of course this is a pretty contrived example: most eggs are not this complicated. So I guess this "bug" should be considered to be in coops after all.

comment:7 Changed 3 years ago by sjamaan

  • Summary changed from Cannot install coops with CHICKEN 4.10 to chicken-install may fail if TMPDIR is mounted noexec (depending on setup-file details)

comment:8 Changed 3 years ago by sjamaan

  • Milestone changed from 4.11.0 to 5.0

I'd say this is a setup-file problem specific to the egg. We may be able to fix this in a general way with the new setup file language in CHICKEN 5, but I doubt it; it's a fundamental problem that you can't load a library at compile time that you've just generated but not yet installed.

In any case, not something that we can fix with CHICKEN 4.

comment:9 Changed 2 years ago by sjamaan

  • Estimated difficulty set to hard

comment:10 Changed 17 months ago by sjamaan

The new setup language cleanly separates build from install, which means the problem still exists.

I think the clean separation is desirable because you want to be able to build separately, and also because if the building of coops works and is installed, but coops-primitive-objects fails, this means the egg would be half-installed.

I don't know if it's even something we can fix (or even should fix?). Perhaps it should be documented as a limitation. I think even detecting this situation is difficult.

comment:11 follow-up: Changed 17 months ago by felix

Note that in C5, building of eggs takes place in the cache (usually ~/.chicken-install-cache, or $CHICKEN_EGG_CACHE), so $TMPDIR is irrelevant in this case.

comment:12 in reply to: ↑ 11 Changed 17 months ago by iraikov

Oh, it does sound like this might make the issue irrelevant. Apologies for not trying out C5 earlier. Let me just build it and see if I can install eggs with it.

Replying to felix:

Note that in C5, building of eggs takes place in the cache (usually ~/.chicken-install-cache, or $CHICKEN_EGG_CACHE), so $TMPDIR is irrelevant in this case.

comment:13 Changed 11 months ago by sjamaan

  • Resolution set to fixed
  • Status changed from new to closed

Should work with C5. Please reopen if it's not working

Note: See TracTickets for help on using tickets.