freebsd / poudriere

Port/Package build and test system
https://github.com/freebsd/poudriere/wiki
BSD 2-Clause "Simplified" License
394 stars 163 forks source link

qemu user mode doesn't work with memory limit #228

Open AMDmi3 opened 10 years ago

AMDmi3 commented 10 years ago

When MAX_MEMORY is enabled in poudriere config, any build which uses cross compilation with qemu user mode would fail with abort trap.

bdrewery commented 10 years ago

How much memory did you specify?

AMDmi3 commented 10 years ago

8G. You're right, 3 works fine. 7 also works fine (I guess it's trimmed to 32 bits). Poudriere should probably just ignore the limit >=4 for 32bit jails. /usr/bin/limits should also be fixed likely. that's more likely /bin/sh problem see #229

bdrewery commented 10 years ago

I don't understand this. I don't see any overflow. From an i386 system:

# sh -c 'MAX_MEMORY=100; x=$((${MAX_MEMORY} * 1024 * 1024 * 1024)); ulimit -v $x; ulimit -v'
107374182400
bdrewery commented 10 years ago

Even using limits(1):

# sh -c 'MAX_MEMORY=100; x=$((${MAX_MEMORY} * 1024 * 1024 * 1024)); limits -v $x sh -c "ulimit -v"'
104857600
bdrewery commented 10 years ago

Ah! Yes, I misread the 2nd, limits(1) is broken.

bdrewery commented 10 years ago

Actually I see ulimit(1) returns KB. So all is fine.

I see no issue here.

Your proposed patch does the same thing as the original, plus does not work on FreeBSD 8.4.

AMDmi3 commented 10 years ago

Hmm, you are right. I somehow mistested it. However it still aborts with MAX_MEMORY=4, 8 (but not 7), so there definitely is an overflow somewhere. In arm jail:

# /usr/bin/limits -v 4294967295 /bin/sh -c '/usr/bin/limits -v'
Resource limits (current):
  vmemoryuse            4194304 kB
# /usr/bin/limits -v 4294967296 /bin/sh -c '/usr/bin/limits -v'
Abort trap
# /usr/bin/limits -v 5294967296 /bin/sh -c '/usr/bin/limits -v'
Resource limits (current):
  vmemoryuse             976563 kB
AMDmi3 commented 10 years ago

That's not ARM problem, doesn't show up on native ARM. Probably emulation thing.