sergev/LiteBSD

`ed` can't create /tmp/file

majenkotech opened this issue · 5 comments

This looks like a problem with mktemp() not being able to create the scratch file for some reason.

Found (and fixed) the mktemp problem - both a big bug in mktemp() itself, and a bug in ed.

However, I now have a new problem with ed:

# ed
PID 38 (ed) protection violation at 403898: BadVAddr = 0040c710 
Bus error

Now, how can I diagnose that...?

According to a disassembly, 403898 is:

  403898:   08100e1d    j   403874 <mktemp_internal+0xb8>

This is within mktemp_internal. That's not 0040c710...!

This jump instruction has a store-byte in delay slot:

    a062ffff        sb      v0,-1(v1)

Isn't it trying to store something to .text segment, which is read-only?

Huh, I see what's the problem. In ed.c, function mktemp() is called with const argument:

    tfname = mktemp("/tmp/eXXXXX");

Aha, you're quite right there. Cryptic error for something so obvious... That I can fix.

We now have a working ed.

Perfect.
I assumed GCC should give a warning in this case, when -Wall enabled, but it does not.