michaelforney / samurai

ninja-compatible build tool written in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

samu segfaults with -n when default target is "phony file"

ptrcnull opened this issue · comments

Minimal setup to reproduce:

build.ninja:

rule echo
 command = echo $out

build output: echo build.ninja
build all: phony output

default all
# samu -n
[1/1] echo output
[1]    12762 segmentation fault  samu -n

Backtrace:

# gdb /usr/bin/samu ./core
GNU gdb (GDB) 11.2
(...)
Reading symbols from /usr/bin/samu...
[New LWP 12846]
Core was generated by `samu -n'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f59ad7c3871 in strlen (s=<optimized out>, 
    s@entry=0x8 <error: Cannot access memory at address 0x8>) at src/string/strlen.c:17
17	src/string/strlen.c: No such file or directory.
(gdb) bt full
#0  0x00007f59ad7c3871 in strlen (s=<optimized out>, s@entry=0x8 <error: Cannot access memory at address 0x8>) at src/string/strlen.c:17
        a = 0x8 <error: Cannot access memory at address 0x8>
        w = 0x8
#1  0x00007f59ad7bbda3 in fputs (s=s@entry=0x8 <error: Cannot access memory at address 0x8>, f=0x7f59ad8072c0 <__stdout_FILE>) at src/stdio/fputs.c:6
        l = <optimized out>
#2  0x00007f59ad7bd96b in puts (s=s@entry=0x8 <error: Cannot access memory at address 0x8>) at src/stdio/puts.c:7
        r = <optimized out>
        __need_unlock = 0
#3  0x00005620f4377f68 in printstatus (e=e@entry=0x5620f4382cd0, cmd=<optimized out>) at build.c:273
        description = 0x0
        status = "[2/1] \000\000\020\350g\373\374\177\000\000P\347g\373\374\177\000\000\b\000\000\000\000\000\000\000\t&\fb\000\000\000\000\026T\261\026\000\000\000\000\001\000\000\000\000\000\000\000\000 \000\000\000\000\000\000\372L\200\255Y\177\000\000F1`(", '\000' <repeats 28 times>, "(\351g\373\374\177\000\000\060\241\200\255Y\177\000\000\060\241\200\255Y\177\000\000\373\036y\255Y\177\000\000\337*8\364 V\000\000\255L\200\255Y\177\000\000\306M\200\255Y\177\000\000\246\243\067\364 V\000\000\244\201\000\000\350\003\000\000\001\000\000\001t\000\000\000\001\000\000\000\000\000\000\000\026zy\255Y\177\000\000"...
#4  0x00005620f437841a in build () at build.c:545
        jobs = 0x0
        fds = 0x0
        i = <optimized out>
        next = 0
        jobslen = 0
        numjobs = 0
        numfail = 0
        e = 0x5620f4382cd0
#5  0x00005620f4377a00 in main (argc=<optimized out>, argv=0x7ffcfb67ea28) at samu.c:256
        builddir = <optimized out>
        manifest = 0x5620f437eb18 "build.ninja"
        end = 0x0
        arg = <optimized out>
        tool = <optimized out>
        n = <optimized out>
        num = <optimized out>
        tries = 0
(gdb)

for the record, meson seems to use this type of target, so it fails when using meson compile -C build --ninja-args=-n - discovered while trying to run meson testsuite with samu: https://gitlab.alpinelinux.org/alpine/aports/-/jobs/632368#L1001

Duplicate of #66 and should be fixed in git master.

ah, that does indeed fix it.