Fossil SCM
Add a test script that runs one thousand web page queries using valgrind, looking for memory issues. Fix one use-after-free issue found using this script.
Commit
9e0da27437da80b3b89ab798da693e5b67c9175a
Parent
d5c46845080ed03…
2 files changed
+1
-1
+33
+1
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1723,14 +1723,14 @@ | ||
| 1723 | 1723 | } |
| 1724 | 1724 | @ <tr><th>Ticket:</th> |
| 1725 | 1725 | @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a></td></tr> |
| 1726 | 1726 | @ <tr><th>Date:</th><td> |
| 1727 | 1727 | hyperlink_to_date(zDate, "</td></tr>"); |
| 1728 | - free(zDate); | |
| 1729 | 1728 | @ <tr><th>User:</th><td> |
| 1730 | 1729 | hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>"); |
| 1731 | 1730 | @ </table> |
| 1731 | + free(zDate); | |
| 1732 | 1732 | |
| 1733 | 1733 | if( g.perm.ModTkt && modPending ){ |
| 1734 | 1734 | @ <div class="section">Moderation</div> |
| 1735 | 1735 | @ <blockquote> |
| 1736 | 1736 | @ <form method="POST" action="%R/tinfo/%s(zUuid)"> |
| 1737 | 1737 | |
| 1738 | 1738 | ADDED test/valgrind-www.tcl |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1723,14 +1723,14 @@ | |
| 1723 | } |
| 1724 | @ <tr><th>Ticket:</th> |
| 1725 | @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a></td></tr> |
| 1726 | @ <tr><th>Date:</th><td> |
| 1727 | hyperlink_to_date(zDate, "</td></tr>"); |
| 1728 | free(zDate); |
| 1729 | @ <tr><th>User:</th><td> |
| 1730 | hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>"); |
| 1731 | @ </table> |
| 1732 | |
| 1733 | if( g.perm.ModTkt && modPending ){ |
| 1734 | @ <div class="section">Moderation</div> |
| 1735 | @ <blockquote> |
| 1736 | @ <form method="POST" action="%R/tinfo/%s(zUuid)"> |
| 1737 | |
| 1738 | DDED test/valgrind-www.tcl |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1723,14 +1723,14 @@ | |
| 1723 | } |
| 1724 | @ <tr><th>Ticket:</th> |
| 1725 | @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a></td></tr> |
| 1726 | @ <tr><th>Date:</th><td> |
| 1727 | hyperlink_to_date(zDate, "</td></tr>"); |
| 1728 | @ <tr><th>User:</th><td> |
| 1729 | hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>"); |
| 1730 | @ </table> |
| 1731 | free(zDate); |
| 1732 | |
| 1733 | if( g.perm.ModTkt && modPending ){ |
| 1734 | @ <div class="section">Moderation</div> |
| 1735 | @ <blockquote> |
| 1736 | @ <form method="POST" action="%R/tinfo/%s(zUuid)"> |
| 1737 | |
| 1738 | DDED test/valgrind-www.tcl |
+33
| --- a/test/valgrind-www.tcl | ||
| +++ b/test/valgrind-www.tcl | ||
| @@ -0,0 +1,33 @@ | ||
| 1 | +#!/usr/bin/tclsh | |
| 2 | +# | |
| 3 | +# Run this script in an open Fossil checkout at the top-level with a | |
| 4 | +# fresh build of Fossil itself. This script will run fossil on hundreds | |
| 5 | +# of different web-pages looking for memory allocation problems using y allocation problems using | |
| 6 | +# valgrind. Valgrind output appears on stderr. Suggested test scenario: | |
| 7 | +# | |
| 8 | +# make | |
| 9 | +# tclsh valgrind-www.tcl 2>&1 | tee valgrind-out.txt | |
| 10 | +# | |
| 11 | +# Then examine the valgrind-out.txt file for issues. | |
| 12 | +# | |
| 13 | +proc run_query {url} { | |
| 14 | + set fd [open q.txt w] | |
| 15 | + puts $fd "GET $url HTTreturn [url HTTP/1.0\r\n\r" | |
| 16 | + c]/fossil test-http <q.txt 2>@ stderr} msg | |
| 17 | + return $msg | |
| 18 | +} | |
| 19 | +set todo {} | |
| 20 | +foreach url { | |
| 21 | + /home | |
| 22 | + /timeli/tclsh | |
| 23 | +# | |
| 24 | +# Run this scrip#!/usr/bin/tclsh | |
| 25 | +# | |
| 26 | +# Run this script in an open Fossil checkout at the top-lding>0 && $i<$limit} {incr i} { | |
| 27 | + set url [get_pending] | |
| 28 | + puts "====== ([expr {$i+1}]) $url ======" | |
| 29 | + set x [run_query $url] | |
| 30 | + while {[regexp {<[aA] .*?href="(/[a-z].*?)".*?>(.*)$} $x all url tail]} { | |
| 31 | + set u2 [string map {< < > > " \" & &} $url] | |
| 32 | + if {![info exists seen($u2)]} { | |
| 33 | + set pendlappend tod |
| --- a/test/valgrind-www.tcl | |
| +++ b/test/valgrind-www.tcl | |
| @@ -0,0 +1,33 @@ | |
| --- a/test/valgrind-www.tcl | |
| +++ b/test/valgrind-www.tcl | |
| @@ -0,0 +1,33 @@ | |
| 1 | #!/usr/bin/tclsh |
| 2 | # |
| 3 | # Run this script in an open Fossil checkout at the top-level with a |
| 4 | # fresh build of Fossil itself. This script will run fossil on hundreds |
| 5 | # of different web-pages looking for memory allocation problems using y allocation problems using |
| 6 | # valgrind. Valgrind output appears on stderr. Suggested test scenario: |
| 7 | # |
| 8 | # make |
| 9 | # tclsh valgrind-www.tcl 2>&1 | tee valgrind-out.txt |
| 10 | # |
| 11 | # Then examine the valgrind-out.txt file for issues. |
| 12 | # |
| 13 | proc run_query {url} { |
| 14 | set fd [open q.txt w] |
| 15 | puts $fd "GET $url HTTreturn [url HTTP/1.0\r\n\r" |
| 16 | c]/fossil test-http <q.txt 2>@ stderr} msg |
| 17 | return $msg |
| 18 | } |
| 19 | set todo {} |
| 20 | foreach url { |
| 21 | /home |
| 22 | /timeli/tclsh |
| 23 | # |
| 24 | # Run this scrip#!/usr/bin/tclsh |
| 25 | # |
| 26 | # Run this script in an open Fossil checkout at the top-lding>0 && $i<$limit} {incr i} { |
| 27 | set url [get_pending] |
| 28 | puts "====== ([expr {$i+1}]) $url ======" |
| 29 | set x [run_query $url] |
| 30 | while {[regexp {<[aA] .*?href="(/[a-z].*?)".*?>(.*)$} $x all url tail]} { |
| 31 | set u2 [string map {< < > > " \" & &} $url] |
| 32 | if {![info exists seen($u2)]} { |
| 33 | set pendlappend tod |