Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plumber: write to plumb/rules doesn't load rules from include statements #256

Closed
fhs opened this issue Apr 29, 2019 · 4 comments · Fixed by #257
Closed

plumber: write to plumb/rules doesn't load rules from include statements #256

fhs opened this issue Apr 29, 2019 · 4 comments · Fixed by #257

Comments

@fhs
Copy link
Contributor

fhs commented Apr 29, 2019

$ echo include $PLAN9/plumb/initial.plumbing > $HOME/lib/plumbing
$ plumber
$ 9p read plumb/rules | wc
    144     385    3366
$ cat $HOME/lib/plumbing | 9p write plumb/rules
$ 9p read plumb/rules | wc
     20      32     313
$ 9p read plumb/rules 
plan9=/usr/local/plan9

editor=acme

addrelem='((#?[0-9]+)|(/[A-Za-z0-9_\^]+/?)|[.$])'

addr=:($addrelem([,;+\-]$addrelem)*)

twocolonaddr=([0-9]+)[:.]([0-9]+)

plumb to seemail
plumb to showmail
plumb to web
plumb to msword
plumb to image
plumb to postscript
plumb to openoffice
plumb to edit
plumb to sendmail

$
fhs added a commit to 9fans/acme-lsp that referenced this issue Apr 29, 2019
Pass address directly as an attribute, so we don't rely on the standard
plumbing rules to be loaded. This problematic especially since reloading
rules is broken: 9fans/plan9port#256

Update #3
@mkhl
Copy link
Contributor

mkhl commented Apr 30, 2019

FWIW, I can reproduce this on linux but it seems to work fine on macOS.

@mkhl
Copy link
Contributor

mkhl commented Apr 30, 2019

…it also seems to work on Linux when built with clang

@fhs
Copy link
Contributor Author

fhs commented Apr 30, 2019

I can't reproduce anymore with gcc -O0 although sometimes I get 9p: write error: unknown object b.

$ gcc --version
gcc (GCC) 8.3.0

@fhs
Copy link
Contributor Author

fhs commented May 1, 2019

I have a fix I'll send out later today. Plumber isn't detecting EOF correctly.

fhs added a commit to fhs/plan9port that referenced this issue May 1, 2019
Instead of checking Fcall.data==nil, check Fcall.count==0.
The former check always fails after `gcc -O2` optimizations
(gcc version 8.3.0).

Also fix an out-of-bound read detected by valgrind:
```
==31162== Invalid read of size 1
==31162==    at 0x11005E: morerules (rules.c:739)
==31162==    by 0x110254: writerules (rules.c:775)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
==31162==  Address 0x4ea984a is 0 bytes after a block of size 250 alloc'd
==31162==    at 0x483AD7B: realloc (vg_replace_malloc.c:826)
==31162==    by 0x1196F3: p9realloc (malloc.c:53)
==31162==    by 0x10BDFD: erealloc (plumber.c:124)
==31162==    by 0x10FCD9: concat (rules.c:642)
==31162==    by 0x10FCD9: concat (rules.c:635)
==31162==    by 0x110230: writerules (rules.c:773)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
```

Fixes 9fans#256
jxy pushed a commit to jxy/plan9port that referenced this issue Jun 5, 2019
Instead of checking Fcall.data==nil, check Fcall.count==0.
The former check always fails after `gcc -O2` optimizations
(gcc version 8.3.0).

Also fix an out-of-bound read detected by valgrind:
```
==31162== Invalid read of size 1
==31162==    at 0x11005E: morerules (rules.c:739)
==31162==    by 0x110254: writerules (rules.c:775)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
==31162==  Address 0x4ea984a is 0 bytes after a block of size 250 alloc'd
==31162==    at 0x483AD7B: realloc (vg_replace_malloc.c:826)
==31162==    by 0x1196F3: p9realloc (malloc.c:53)
==31162==    by 0x10BDFD: erealloc (plumber.c:124)
==31162==    by 0x10FCD9: concat (rules.c:642)
==31162==    by 0x10FCD9: concat (rules.c:635)
==31162==    by 0x110230: writerules (rules.c:773)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
```

Fixes 9fans#256
dancrossnyc pushed a commit that referenced this issue Sep 19, 2019
Instead of checking Fcall.data==nil, check Fcall.count==0.
The former check always fails after `gcc -O2` optimizations
(gcc version 8.3.0).

Also fix an out-of-bound read detected by valgrind:
```
==31162== Invalid read of size 1
==31162==    at 0x11005E: morerules (rules.c:739)
==31162==    by 0x110254: writerules (rules.c:775)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
==31162==  Address 0x4ea984a is 0 bytes after a block of size 250 alloc'd
==31162==    at 0x483AD7B: realloc (vg_replace_malloc.c:826)
==31162==    by 0x1196F3: p9realloc (malloc.c:53)
==31162==    by 0x10BDFD: erealloc (plumber.c:124)
==31162==    by 0x10FCD9: concat (rules.c:642)
==31162==    by 0x10FCD9: concat (rules.c:635)
==31162==    by 0x110230: writerules (rules.c:773)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
```

Fixes #256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants