Discussion:
Segfault on json test
(too old to reply)
Dingyuan Wang
2018-07-05 15:38:22 UTC
Permalink
Hi,

The following test:

tclsh test/tester.tcl fossil json

fails with:

[...]
/home/gumble/dev/fossil/fossil json --json-input anon-1
ERROR: child killed: segmentation violation
JSON ERROR: unexpected token ":" at position 1; expecting VALUE
test json-login-a-env-validJSON FAILED!
test test-framework-json FAILED!
!!!!! json: key "payload" not known in dictionary
-code = 1
-level = 0
-errorstack = INNER dictGet CALL {test_json_payload json-login-a
{authToken name capabilities loginCookieName} {}}
-errorcode = TCL LOOKUP DICT payload
-errorinfo = key "payload" not known in dictionary
while executing
"dict get $::JR payload"
(procedure "test_json_payload" line 2)
invoked from within
"test_json_payload json-login-a {authToken name capabilities
loginCookieName} {}"
(file "/home/gumble/dev/fossil/test/json.test" line 263)
invoked from within
"source $testdir/$testfile.test"
-errorline = 1"
***** End of json: 3 errors so far ******
***** Final results: 3 errors out of 121 tests
***** Considered failures: json-1 json-login-a-env-validJSON
test-framework-json
***** Ignored results: 0 ignored errors out of 121 tests

The stack trace shows:

#0 0x000055d0cdf3c39e in cgi_set_cookie (
zName=***@entry=0x55d0ceaad160 "fossil-5617be7b37c6ab30",
zValue=***@entry=0x55d0ceaabaa0
"97fd92d7871e141066b93aedca178577682f732f/2458305.14815368/anonymous",
zPath=0x0, lifetime=***@entry=21600)
at ./src/cgi.c:216
216 if( zPath[0]==0 ) zPath = "/";
#1 0x000055d0cdf835e2 in login_set_anon_cookie (zIpAddr=<optimized out>,
***@entry=0x0, zCookieDest=***@entry=0x7ffef7822f88)
at ./src/login.c:329
#2 0x000055d0cdf7daba in json_page_login () at ./src/json_login.c:151
#3 0x000055d0cdf7a89f in json_dispatch_root_command (
zCommand=0x55d0ceac516c "login") at ./src/json.c:2209
#4 0x000055d0cdf7abab in json_cmd_top () at ./src/json.c:2313
#5 0x000055d0cdf2bb9e in main (argc=<optimized out>, argv=<optimized out>)
at ./src/main.c:760

Therefore, this commit
https://www.fossil-scm.org/index.html/info/0a1f4ed6aa92f130
introduces the problem.
Stephan Beal
2018-07-05 16:31:30 UTC
Permalink
Post by Dingyuan Wang
tclsh test/tester.tcl fossil json
i believe the fix is simply:

[***@host:~/fossil/fossil]$ f diff
Index: src/cgi.c
==================================================================
--- src/cgi.c
+++ src/cgi.c
@@ -211,11 +211,12 @@
const char *zValue, /* Value of the cookie. Automatically escaped */
const char *zPath, /* Path cookie applies to. NULL means "/" */
int lifetime /* Expiration of the cookie in seconds from now */
){
char *zSecure = "";
- if( zPath==0 ){
+ if(!g.isHTTP) return /* likely JSON CLI mode */;
+ else if( zPath==0 ){
zPath = g.zTop;
if( zPath[0]==0 ) zPath = "/";
}
if( g.zBaseURL!=0 && strncmp(g.zBaseURL, "https:", 6)==0 ){
zSecure = " secure;";


but i need to test more before committing.
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
Stephan Beal
2018-07-05 16:53:29 UTC
Permalink
Post by Dingyuan Wang
Hi,
tclsh test/tester.tcl fossil json
[...]
/home/gumble/dev/fossil/fossil json --json-input anon-1
ERROR: child killed: segmentation violation
https://www.fossil-scm.org/index.html/info/f488a5aa97a3b15f

There are still 2 json tests which fail, but i didn't write those and can't
say anything useful about them :/. The segfault is resolved, in any case.

Thanks for the report!
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
Loading...