# Linux Kernel Module Cheat

#### 11.4.2. stack smashing detected when using glibc

For some reason QEMU / glibc x86_64 picks up the host libc, which breaks things.

Other archs work as they different host libc is skipped. User mode static executables also work.

We have worked around this with with https://bugs.launchpad.net/qemu/+bug/1701798/comments/12 from the thread: https://bugs.launchpad.net/qemu/+bug/1701798 by creating the file: rootfs_overlay/etc/ld.so.cache which is a symlink to a file that cannot exist: `/dev/null/nonexistent`.

Reproduction:

    rm -f "$(./getvar buildroot_target_dir)/etc/ld.so.cache"
    ./run --userland userland/c/hello.c
    ./run --userland userland/c/hello.c --qemu-which host

Outcome:

    *** stack smashing detected ***: <unknown> terminated
    qemu: uncaught target signal 6 (Aborted) - core dumped

To get things working again, restore `ld.so.cache` with:

    ./build-buildroot

I’ve also tested on an Ubuntu 16.04 guest and the failure is different one:

    qemu: uncaught target signal 4 (Illegal instruction) - core dumped

A non-QEMU-specific example of stack smashing is shown at: https://stackoverflow.com/questions/1345670/stack-smashing-detected/51897264#51897264

Tested at: 2e32389ebf1bedd89c682aa7b8fe42c3c0cf96e5 + 1.