Hi,

I don't know if this is the right forum for this (if not, please point
me in the right direction). I'm having some issues with Make. After
upgrading to Ubuntu 22.04 I started getting Segmentation Fault in Make
when building a project at work. I did some testing around and the
following are my findings.

Make segfaults with the binary available on Ubuntu 22.04 (Make-4.3), but
not the one on Ubuntu 21.10 (Make-4.3). It also works fine on Ubuntu
20.04 with Make-4.2.1.

I had a colleague send me his binary from 21.10 and it works fine, while
mine on 22.04 does not. Both are Make-4.3. Building Make-4.3 from source
also causes the segfault, which makes it seem like Ubuntu has done some
modification that even made it work initially. But that change has now
been undone?

Also, building the latest Make from source does not cause any segfault. But
it seems to have reworked the part that crashes and possibly a lot more.
So it is no longer an issue upstream.

The cause of the segfault is at `src/function.c` at function
`func_filter_filterout` at the following code. The alloca keeps
allocating on the stack until it goes outside memory and causes write
outside its own memory.

while ((p = find_next_token (&word_iterator, &len)) != 0) {
        struct a_word *word = alloca (sizeof (struct a_word));

        *wordtail = word;
        wordtail = &word->next;

        if (*word_iterator != '\0')
                ++word_iterator;

        p[len] = '\0';
        word->str = p;
        word->length = len;
        word->matched = 0;
        word->chain = 0;
        words++;
}

Though, the root cause seems to be different because this code is the
same in the different versions of Ubuntu's Make source code. When it
segfaults this part seems to be iterating over many things which it
should not iterate over.

The project I'm building is based on Buildroot. Regarding that, it
seems to be failing between the Configuration and the Build step. It
finishes Configuration, but never reaches the start of Build. This only
seems to happen when `modules` package is pointing to a separate folder
of modules. If I put the `hello` module as a normal package there is no
issue building it.

Run the commands below to recreate. Note that the initial build will
take some time, as it has to build the Linux kernel.
$ git clone https://github.com/westermo/netbox/tree/make-bug
$ cd netbox
$ make netbox_os_zero_defconfig
$ make
$ make modules-reconfigure # segfault happens here

After that, the last command can be repeated to test building the
modules.

I had several other colleagues try this on their computers as well, and
the result was the same. Segfault on Ubuntu 22.04, but not on earlier
versions.

Best Regards,
Casper

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss

Reply via email to