(*TLS).Free: free of unallocated memory
@amfiremage While trying to figure out Tk failures that I suspect are caused by corrupt memory, it seems memgrind noticed a bug in TLS stack headers handling. (Provided latest memgrind checks are not broken themselves. Some other tests pass with it normally.) Steps to reproduce: 1) Get cznic/sqlite@612508d1. That will use latest libc@b71739ce. Then ``` jnml@e5-1650:~$ cd sqlite /home/jnml/src/modernc.org/sqlite jnml@e5-1650:~/src/modernc.org/sqlite$ go test -v -timeout 24h -tags=libc.memgrind -run TestConcurrentProcesses -xtags=libc.memgrind |& tee log test binary compiled for linux/amd64 === RUN TestConcurrentProcesses all_test.go:640: BEGIN: ./mptest db config01.test 2 config01.test With SQLite 3.33.0 2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f -DSQLITE_COMPILER=gcc-8.3.0 -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_RBU -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_SNAPSHOT -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 28908.mptest: begin script [config01.test] cycle 1 28908.mptest: --if vfsname() GLOB 'unix' 28908.mptest: --task 1 28908.mptest: system('./mptest "db" --client 1 --trace 2') 28908.mptest: --task 2 28908.mptest: system('./mptest "db" --client 2 --trace 2') 28908.mptest: --task 3 28908.mptest: system('./mptest "db" --client 3 --trace 2') 28908.mptest: --task 4 28908.mptest: system('./mptest "db" --client 4 --trace 2') 28915.client01: start-client 28915.client01: begin config01.test:6 (1) 28915.client01: end config01.test:6 (1) 28921.client02: start-client 28923.client03: start-client 28934.client04: start-client 28923.client03: begin config01.test:14 (3) 28923.client03: end config01.test:14 (3) 28908.mptest: --task 4 28921.client02: begin config01.test:10 (2) 28921.client02: end config01.test:10 (2) 28908.mptest: --source multiwrite01.test 28908.mptest: begin script [multiwrite01.test] 28908.mptest: --task 1 build-t1 28908.mptest: --task 2 build-t2 28908.mptest: --task 3 build-t3 28908.mptest: --task 4 build-t4 28908.mptest: --task 5 build-t5 28908.mptest: system('./mptest "db" --client 5 --trace 2') 28908.mptest: --wait all 28943.client05: start-client 28943.client05: begin build-t5 (10) 28943.client05: --sleep 1 28943.client05: --sleep 1 28943.client05: --sleep 1 28943.client05: --sleep 1 28943.client05: --match 64 28943.client05: --match 1500.0 28943.client05: --sleep 2 28934.client04: begin config01.test:17 (4) 28934.client04: end config01.test:17 (4) 28915.client01: begin build-t1 (6) 28915.client01: --sleep 1 28921.client02: begin build-t2 (7) 28921.client02: --sleep 1 28934.client04: begin config01.test:20 (5) 28934.client04: end config01.test:20 (5) 28921.client02: --sleep 1 28923.client03: begin build-t3 (8) 28923.client03: --sleep 1 28923.client03: --sleep 1 28915.client01: --sleep 1 28915.client01: --sleep 1 28915.client01: --sleep 1 28915.client01: --match 64 28915.client01: --match 1500.0 28915.client01: --sleep 2 28921.client02: --sleep 1 28923.client03: --sleep 1 28923.client03: --sleep 1 28921.client02: --sleep 1 28921.client02: --match 64 28921.client02: --match 1500.0 28921.client02: --sleep 2 28915.client01: --match 247 28915.client01: --match 17 28921.client02: --match 247 28921.client02: --match 17 28921.client02: --match 17 28921.client02: --match 29 28 27 26 25 28921.client02: end build-t2 (7) 28915.client01: --match 17 28915.client01: --match 29 28 27 26 25 28915.client01: end build-t1 (6) 28934.client04: begin build-t4 (9) 28934.client04: --sleep 1 28934.client04: --sleep 1 28934.client04: --sleep 1 28934.client04: --sleep 1 28934.client04: --match 64 28934.client04: --match 1500.0 28934.client04: --sleep 2 28934.client04: --match 247 28934.client04: --match 17 28934.client04: --match 17 28934.client04: --match 29 28 27 26 25 28934.client04: end build-t4 (9) 28943.client05: --match 247 28943.client05: --match 17 28943.client05: --match 17 28943.client05: --match 29 28 27 26 25 28943.client05: end build-t5 (10) 28923.client03: --match 64 28923.client03: --match 1500.0 28923.client03: --sleep 2 28923.client03: --match 247 28923.client03: --match 17 28923.client03: --match 17 28923.client03: --match 29 28 27 26 25 28923.client03: end build-t3 (8) 28908.mptest: --match 64 247 28908.mptest: --match 64 247 28908.mptest: --match 64 247 28908.mptest: --match 64 247 28908.mptest: --match 64 247 28908.mptest: --task 1 28908.mptest: --task 5 28908.mptest: --task 3 28908.mptest: --task 2 28908.mptest: --task 4 28908.mptest: --wait all 28921.client02: begin multiwrite01.test:203 (14) 28921.client02: --match 33 34 35 36 28921.client02: --match 45 46 47 48 49 50 51 28921.client02: end multiwrite01.test:203 (14) 28934.client04: begin multiwrite01.test:213 (15) 28934.client04: --match 33 34 35 36 28934.client04: --match 45 46 47 48 49 50 51 28934.client04: end multiwrite01.test:213 (15) 28943.client05: begin multiwrite01.test:183 (12) 28943.client05: --match 33 34 35 36 28943.client05: --match 45 46 47 48 49 50 51 28943.client05: end multiwrite01.test:183 (12) 28915.client01: begin multiwrite01.test:173 (11) 28915.client01: --match 33 34 35 36 28915.client01: --match 45 46 47 48 49 50 51 28915.client01: end multiwrite01.test:173 (11) 28923.client03: begin multiwrite01.test:193 (13) 28923.client03: --match 33 34 35 36 28923.client03: --match 45 46 47 48 49 50 51 28923.client03: end multiwrite01.test:193 (13) 28908.mptest: --task 5 28908.mptest: --task 3 28908.mptest: --task 1 28908.mptest: --task 2 28908.mptest: --task 4 28908.mptest: --wait all 28934.client04: begin multiwrite01.test:253 (20) 28934.client04: --sleep 5 28943.client05: begin multiwrite01.test:225 (16) 28943.client05: --sleep 5 28934.client04: --match ok 28915.client01: begin multiwrite01.test:239 (18) 28915.client01: --sleep 5 28934.client04: end multiwrite01.test:253 (20) 28943.client05: --match ok 28915.client01: --match ok 28921.client02: begin multiwrite01.test:246 (19) 28921.client02: --sleep 5 28923.client03: begin multiwrite01.test:232 (17) 28923.client03: --sleep 5 28915.client01: end multiwrite01.test:239 (18) 28921.client02: --match ok 28923.client03: --match ok 28921.client02: end multiwrite01.test:246 (19) 28923.client03: end multiwrite01.test:232 (17) 28943.client05: end multiwrite01.test:225 (16) 28908.mptest: --task 1 28908.mptest: --task 5 28908.mptest: --task 3 28908.mptest: --task 2 28908.mptest: --task 4 28908.mptest: --wait all 28921.client02: begin multiwrite01.test:292 (24) 28921.client02: --match 33 34 35 36 28921.client02: --match 45 46 47 48 49 50 51 28921.client02: end multiwrite01.test:292 (24) 28934.client04: begin multiwrite01.test:302 (25) 28934.client04: --match 33 34 35 36 28934.client04: --match 45 46 47 48 49 50 51 28934.client04: end multiwrite01.test:302 (25) 28915.client01: begin multiwrite01.test:262 (21) 28915.client01: --match 33 34 35 36 28915.client01: --match 45 46 47 48 49 50 51 28915.client01: end multiwrite01.test:262 (21) 28923.client03: begin multiwrite01.test:282 (23) 28923.client03: --match 33 34 35 36 28923.client03: --match 45 46 47 48 49 50 51 28923.client03: end multiwrite01.test:282 (23) 28943.client05: begin multiwrite01.test:272 (22) 28943.client05: --match 33 34 35 36 28943.client05: --match 45 46 47 48 49 50 51 28943.client05: end multiwrite01.test:272 (22) 28908.mptest: --match ok 28908.mptest: --task 1 28908.mptest: --task 2 28908.mptest: --task 3 28908.mptest: --task 4 28908.mptest: --task 5 28908.mptest: --wait all 28934.client04: begin multiwrite01.test:339 (29) 28934.client04: --sleep 5 28923.client03: begin multiwrite01.test:332 (28) 28923.client03: --sleep 5 28943.client05: begin multiwrite01.test:346 (30) 28943.client05: --sleep 5 28923.client03: --match 63 28923.client03: end multiwrite01.test:332 (28) 28934.client04: --match 63 28934.client04: end multiwrite01.test:339 (29) 28921.client02: begin multiwrite01.test:325 (27) 28921.client02: --sleep 5 28943.client05: --match 63 28943.client05: end multiwrite01.test:346 (30) 28915.client01: begin multiwrite01.test:318 (26) 28915.client01: --sleep 5 28915.client01: --match 63 28915.client01: end multiwrite01.test:318 (26) 28921.client02: --match 63 28921.client02: end multiwrite01.test:325 (27) 28908.mptest: --task 1 28908.mptest: --task 5 28908.mptest: --task 3 28908.mptest: --task 2 28908.mptest: --task 4 28908.mptest: --wait all 28923.client03: begin multiwrite01.test:379 (33) 28923.client03: --match 33 34 35 36 28923.client03: --match 45 46 47 48 49 50 51 28915.client01: begin multiwrite01.test:355 (31) 28915.client01: --match 33 34 35 36 28915.client01: --match 45 46 47 48 49 50 51 28923.client03: --match ok 28923.client03: end multiwrite01.test:379 (33) 28915.client01: --match ok 28915.client01: end multiwrite01.test:355 (31) 28943.client05: begin multiwrite01.test:367 (32) 28943.client05: --match 33 34 35 36 28943.client05: --match 45 46 47 48 49 50 51 28943.client05: --match ok 28943.client05: end multiwrite01.test:367 (32) 28934.client04: begin multiwrite01.test:403 (35) 28934.client04: --match 33 34 35 36 28934.client04: --match 45 46 47 48 49 50 51 28934.client04: --match ok 28934.client04: end multiwrite01.test:403 (35) 28921.client02: begin multiwrite01.test:391 (34) 28921.client02: --match 33 34 35 36 28921.client02: --match 45 46 47 48 49 50 51 28921.client02: --match ok 28921.client02: end multiwrite01.test:391 (34) 28908.mptest: end script [multiwrite01.test] 28908.mptest: --wait all 28908.mptest: --task 1 28908.mptest: --task 2 28908.mptest: --task 3 28908.mptest: --task 4 28908.mptest: --task 5 28908.mptest: --source multiwrite01.test 28908.mptest: begin script [multiwrite01.test] 28908.mptest: --task 1 build-t1 28908.mptest: --task 2 build-t2 28908.mptest: --task 3 build-t3 28908.mptest: --task 4 build-t4 28908.mptest: --task 5 build-t5 28908.mptest: --wait all 28915.client01: begin config01.test:28 (36) 28915.client01: end config01.test:28 (36) 28915.client01: begin build-t1 (41) 28915.client01: --sleep 1 28915.client01: --sleep 1 28915.client01: --sleep 1 28934.client04: begin config01.test:37 (39) 28934.client04: end config01.test:37 (39) 28943.client05: begin config01.test:40 (40) 28943.client05: end config01.test:40 (40) 28921.client02: begin config01.test:31 (37) 28921.client02: end config01.test:31 (37) 28915.client01: --sleep 1 28943.client05: begin build-t5 (45) 28943.client05: --sleep 1 28934.client04: begin build-t4 (44) 28915.client01: --match 64 28915.client01: --match 1500.0 28915.client01: --sleep 2 28921.client02: begin build-t2 (42) 28921.client02: --sleep 1 28921.client02: --sleep 1 28921.client02: --sleep 1 28921.client02: --sleep 1 28921.client02: --match 64 28921.client02: --match 1500.0 28921.client02: --sleep 2 28934.client04: --sleep 1 28934.client04: --sleep 1 28934.client04: --sleep 1 28934.client04: --sleep 1 28934.client04: --match 64 28934.client04: --match 1500.0 28934.client04: --sleep 2 28915.client01: --match 247 28915.client01: --match 17 28934.client04: --match 247 28934.client04: --match 17 28934.client04: --match 17 28934.client04: --match 29 28 27 26 25 28934.client04: end build-t4 (44) 28943.client05: --sleep 1 28943.client05: --sleep 1 28943.client05: --sleep 1 28915.client01: --match 17 28915.client01: --match 29 28 27 26 25 28915.client01: end build-t1 (41) 28943.client05: --match 64 28943.client05: --match 1500.0 28943.client05: --sleep 2 28943.client05: --match 247 28943.client05: --match 17 28943.client05: --match 17 28943.client05: --match 29 28 27 26 25 28943.client05: end build-t5 (45) 28921.client02: --match 247 28921.client02: --match 17 28921.client02: --match 17 28921.client02: --match 29 28 27 26 25 28921.client02: end build-t2 (42) 28923.client03: begin config01.test:34 (38) 28923.client03: end config01.test:34 (38) 28923.client03: begin build-t3 (43) 28923.client03: --sleep 1 28923.client03: --sleep 1 28923.client03: --sleep 1 28923.client03: --sleep 1 28923.client03: --match 64 28923.client03: --match 1500.0 28923.client03: --sleep 2 28923.client03: --match 247 28923.client03: --match 17 28923.client03: --match 17 28923.client03: --match 29 28 27 26 25 28923.client03: end build-t3 (43) 28908.mptest: --match 64 247 28908.mptest: --match 64 247 28908.mptest: --match 64 247 28908.mptest: --match 64 247 28908.mptest: --match 64 247 28908.mptest: --task 1 28908.mptest: --task 5 28908.mptest: --task 3 28908.mptest: --task 2 28908.mptest: --task 4 28908.mptest: --wait all 28943.client05: begin multiwrite01.test:183 (47) 28943.client05: --match 33 34 35 36 28943.client05: --match 45 46 47 48 49 50 51 28943.client05: end multiwrite01.test:183 (47) 28915.client01: begin multiwrite01.test:173 (46) 28915.client01: --match 33 34 35 36 28915.client01: --match 45 46 47 48 49 50 51 28915.client01: end multiwrite01.test:173 (46) 28934.client04: begin multiwrite01.test:213 (50) 28934.client04: --match 33 34 35 36 28934.client04: --match 45 46 47 48 49 50 51 28934.client04: end multiwrite01.test:213 (50) 28921.client02: begin multiwrite01.test:203 (49) 28921.client02: --match 33 34 35 36 28921.client02: --match 45 46 47 48 49 50 51 28921.client02: end multiwrite01.test:203 (49) 28923.client03: begin multiwrite01.test:193 (48) 28923.client03: --match 33 34 35 36 28923.client03: --match 45 46 47 48 49 50 51 28923.client03: end multiwrite01.test:193 (48) 28908.mptest: --task 5 28908.mptest: --task 3 28908.mptest: --task 1 28908.mptest: --task 2 28908.mptest: --task 4 28908.mptest: --wait all 28934.client04: begin multiwrite01.test:253 (55) 28934.client04: --sleep 5 28934.client04: --match ok 28934.client04: end multiwrite01.test:253 (55) 28943.client05: begin multiwrite01.test:225 (51) 28943.client05: --sleep 5 28923.client03: begin multiwrite01.test:232 (52) 28923.client03: --sleep 5 28915.client01: begin multiwrite01.test:239 (53) 28915.client01: --sleep 5 28921.client02: begin multiwrite01.test:246 (54) 28921.client02: --sleep 5 28915.client01: --match ok 28923.client03: --match ok 28943.client05: --match ok 28923.client03: end multiwrite01.test:232 (52) 28921.client02: --match ok 28915.client01: end multiwrite01.test:239 (53) 28943.client05: end multiwrite01.test:225 (51) 28921.client02: end multiwrite01.test:246 (54) 28908.mptest: --task 1 28908.mptest: --task 5 28908.mptest: --task 3 28908.mptest: --task 2 28908.mptest: --task 4 28921.client02: begin multiwrite01.test:292 (59) 28921.client02: --match 33 34 35 36 28921.client02: --match 45 46 47 48 49 50 51 28921.client02: end multiwrite01.test:292 (59) 28915.client01: begin multiwrite01.test:262 (56) 28915.client01: --match 33 34 35 36 28915.client01: --match 45 46 47 48 49 50 51 28915.client01: end multiwrite01.test:262 (56) 28908.mptest: --wait all 28923.client03: begin multiwrite01.test:282 (58) 28923.client03: --match 33 34 35 36 28923.client03: --match 45 46 47 48 49 50 51 28923.client03: end multiwrite01.test:282 (58) 28934.client04: begin multiwrite01.test:302 (60) 28934.client04: --match 33 34 35 36 28934.client04: --match 45 46 47 48 49 50 51 28934.client04: end multiwrite01.test:302 (60) 28943.client05: begin multiwrite01.test:272 (57) 28943.client05: --match 33 34 35 36 28943.client05: --match 45 46 47 48 49 50 51 28943.client05: end multiwrite01.test:272 (57) 28908.mptest: --match ok 28908.mptest: --task 1 28908.mptest: --task 2 28908.mptest: --task 3 28908.mptest: --task 4 28908.mptest: --task 5 28921.client02: begin multiwrite01.test:325 (62) 28921.client02: --sleep 5 28921.client02: --match 63 28921.client02: end multiwrite01.test:325 (62) 28915.client01: begin multiwrite01.test:318 (61) 28915.client01: --sleep 5 28934.client04: begin multiwrite01.test:339 (64) 28934.client04: --sleep 5 28908.mptest: --wait all 28923.client03: begin multiwrite01.test:332 (63) 28923.client03: --sleep 5 28934.client04: --match 63 28934.client04: end multiwrite01.test:339 (64) 28923.client03: --match 63 28923.client03: end multiwrite01.test:332 (63) 28943.client05: begin multiwrite01.test:346 (65) 28943.client05: --sleep 5 28915.client01: --match 63 28915.client01: end multiwrite01.test:318 (61) 28943.client05: --match 63 28943.client05: end multiwrite01.test:346 (65) 28908.mptest: --task 1 28908.mptest: --task 5 28908.mptest: --task 3 28908.mptest: --task 2 28908.mptest: --task 4 28908.mptest: --wait all 28923.client03: begin multiwrite01.test:379 (68) 28923.client03: --match 33 34 35 36 28923.client03: --match 45 46 47 48 49 50 51 28923.client03: --match ok 28923.client03: end multiwrite01.test:379 (68) 28934.client04: begin multiwrite01.test:403 (70) 28934.client04: --match 33 34 35 36 28934.client04: --match 45 46 47 48 49 50 51 28934.client04: --match ok 28934.client04: end multiwrite01.test:403 (70) 28921.client02: begin multiwrite01.test:391 (69) 28921.client02: --match 33 34 35 36 28921.client02: --match 45 46 47 48 49 50 51 28915.client01: begin multiwrite01.test:355 (66) 28915.client01: --match 33 34 35 36 28915.client01: --match 45 46 47 48 49 50 51 28915.client01: --match ok 28915.client01: end multiwrite01.test:355 (66) 28921.client02: --match ok 28921.client02: end multiwrite01.test:391 (69) 28943.client05: begin multiwrite01.test:367 (67) 28943.client05: --match 33 34 35 36 28943.client05: --match 45 46 47 48 49 50 51 28943.client05: --match ok 28943.client05: end multiwrite01.test:367 (67) 28908.mptest: end script [multiwrite01.test] 28908.mptest: --wait all 28908.mptest: --match 16384 16384 16384 16384 16384 28908.mptest: end script [config01.test] cycle 1 28943.client05: end-client 28915.client01: end-client panic: /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348:Free: free of unallocated memory: 0x7fc8fc900020 goroutine 1 [running, locked to thread]: modernc.org/libc.Xfree(0xc0001300a0, 0x7fc8fc900020) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/memgrind.go:203 +0x419 modernc.org/libc.(*TLS).Free(0xc0001300a0, 0x4) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348 +0x245 modernc.org/libc.(*TLS).Close(0xc0001300a0) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:226 +0x38 modernc.org/libc.exit(0xc0001300a0, 0x100000000) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:116 +0xf8 modernc.org/libc.Start(0x6f8978) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:96 +0x158 main.main() /home/jnml/src/modernc.org/sqlite/internal/mptest/main_linux_amd64.go:20 +0x2d panic: /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348:Free: free of unallocated memory: 0x7f59d3600020 goroutine 1 [running, locked to thread]: modernc.org/libc.Xfree(0xc0001300a0, 0x7f59d3600020) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/memgrind.go:203 +0x419 modernc.org/libc.(*TLS).Free(0xc0001300a0, 0x4) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348 +0x245 modernc.org/libc.(*TLS).Close(0xc0001300a0) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:226 +0x38 modernc.org/libc.exit(0xc0001300a0, 0x100000000) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:116 +0xf8 modernc.org/libc.Start(0x6f8978) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:96 +0x158 main.main() /home/jnml/src/modernc.org/sqlite/internal/mptest/main_linux_amd64.go:20 +0x2d 28921.client02: end-client panic: /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348:Free: free of unallocated memory: 0x7f112d000020 goroutine 1 [running, locked to thread]: modernc.org/libc.Xfree(0xc0001a00a0, 0x7f112d000020) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/memgrind.go:203 +0x419 modernc.org/libc.(*TLS).Free(0xc0001a00a0, 0x4) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348 +0x245 modernc.org/libc.(*TLS).Close(0xc0001a00a0) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:226 +0x38 modernc.org/libc.exit(0xc0001a00a0, 0x100000000) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:116 +0xf8 modernc.org/libc.Start(0x6f8978) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:96 +0x158 main.main() /home/jnml/src/modernc.org/sqlite/internal/mptest/main_linux_amd64.go:20 +0x2d 28923.client03: end-client panic: /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348:Free: free of unallocated memory: 0x7ff7ad100020 goroutine 1 [running, locked to thread]: modernc.org/libc.Xfree(0xc0002100a0, 0x7ff7ad100020) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/memgrind.go:203 +0x419 modernc.org/libc.(*TLS).Free(0xc0002100a0, 0x4) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348 +0x245 modernc.org/libc.(*TLS).Close(0xc0002100a0) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:226 +0x38 modernc.org/libc.exit(0xc0002100a0, 0x100000000) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:116 +0xf8 modernc.org/libc.Start(0x6f8978) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:96 +0x158 main.main() /home/jnml/src/modernc.org/sqlite/internal/mptest/main_linux_amd64.go:20 +0x2d 28934.client04: end-client panic: /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348:Free: free of unallocated memory: 0x7fb733d00020 goroutine 1 [running, locked to thread]: modernc.org/libc.Xfree(0xc0001300a0, 0x7fb733d00020) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/memgrind.go:203 +0x419 modernc.org/libc.(*TLS).Free(0xc0001300a0, 0x4) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348 +0x245 modernc.org/libc.(*TLS).Close(0xc0001300a0) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:226 +0x38 modernc.org/libc.exit(0xc0001300a0, 0x100000000) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:116 +0xf8 modernc.org/libc.Start(0x6f8978) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:96 +0x158 main.main() /home/jnml/src/modernc.org/sqlite/internal/mptest/main_linux_amd64.go:20 +0x2d Summary: 0 errors out of 163 tests END: ./mptest db config01.test 2 config01.test panic: /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348:Free: free of unallocated memory: 0x7f7785d00020 goroutine 1 [running, locked to thread]: modernc.org/libc.Xfree(0xc00017a0a0, 0x7f7785d00020) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/memgrind.go:203 +0x419 modernc.org/libc.(*TLS).Free(0xc00017a0a0, 0x4) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:348 +0x245 modernc.org/libc.(*TLS).Close(0xc00017a0a0) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/etc.go:226 +0x38 modernc.org/libc.exit(0xc00017a0a0, 0x100000000) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:116 +0xf8 modernc.org/libc.Start(0x6f8978) /home/jnml/pkg/mod/modernc.org/libc@v0.0.0-20210217113501-b71739ce7053/libc.go:96 +0x158 main.main() /home/jnml/src/modernc.org/sqlite/internal/mptest/main_linux_amd64.go:20 +0x2d exit status 2 --- FAIL: TestConcurrentProcesses (6.05s) FAIL exit status 1 FAIL modernc.org/sqlite 6.053s jnml@e5-1650:~/src/modernc.org/sqlite$ ``` The failing line is [here](https://gitlab.com/cznic/libc/-/blob/b71739ce7053f98b0da03358a4a81946d0382260/etc.go#L348): ```go //if we are the first one, just free all of them if t.stack.prev == 0 { for ; ; nstack = *(*stackHeader)(unsafe.Pointer(nstack.next)) { if memgrind { if atomic.AddInt32(&t.stackHeaderBalance, -1) < 0 { panic(todo("negative stack header balance")) } } Xfree(t, nstack.page) // <---- line 348 if nstack.next == 0 { break } } t.stack = stackHeader{} return } ``` Can you please take a look? Thank you.
issue