1
$ /bin/bash -c 'echo qqq'
qqq
$ /lib/ld-linux.so.2 /bin/bash -c 'echo qqq'
/bin/bash: xmalloc: ../bash/variables.c:2176: cannot allocate 3 bytes (8192 bytes allocated)

Why this happens (zsh4, python works well in this use case)? Can it be caused by "prelink"?

2
  • Do you mean LD_PRELINK?
    – djf
    Commented Aug 15, 2012 at 21:38
  • No, prelink (8) - prelink ELF shared libraries and binaries to speed up startup time
    – Vi.
    Commented Aug 15, 2012 at 22:41

2 Answers 2

2

You may be trying to call 64-bit binary with 32-bit lib on amd64 architecture; in my case:

ls -l /lib/ld-linux.so.2
/lib/ld-linux.so.2 -> /lib32/ld-linux.so.2
6
  • /lib/ld-linux.so.2 -> i386-linux-gnu/ld-2.13.so
    – Vi.
    Commented Aug 15, 2012 at 22:41
  • @Vi.: and the output of file /bin/bash is... ?
    – barti_ddu
    Commented Aug 16, 2012 at 15:30
  • /bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xb9a715b5137f1d8d532103e0f7f7a288039bf7f7, stripped
    – Vi.
    Commented Aug 16, 2012 at 18:27
  • @Vi.: hmm, i was pretty sure, that you've mixed 32/64 bit components; what does strace -i /lib/ld-linux.so.2 /bin/bash -c 'echo qqq' produce?
    – barti_ddu
    Commented Aug 16, 2012 at 18:56
  • 1
    @Vi.: nothing criminal except the crash itself :/ however, this (bugs.launchpad.net/ubuntu/+source/bash/+bug/452175) report may be related
    – barti_ddu
    Commented Aug 16, 2012 at 20:07
1

As hinted by barti-ddu, it is likely a bug

The one of workarounds is to disable kernel allocation randomization:

echo 0 > /proc/sys/kernel/randomize_va_space
2
  • i wish you accepted your answer so that it stays on top ;) Concerning va space randomization it is better (if possible) to upgrade the kernel, since disabling it is a security risk. Anyway, glad you've resolved the loader issue, good luck.
    – barti_ddu
    Commented Aug 16, 2012 at 21:32
  • "You can accept your own answer in 22 hours". You can re-post it as your answer, so I'll accept it.
    – Vi.
    Commented Aug 16, 2012 at 22:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .