"save" makes improper [text] strings; impossible to reload

Started by TedWalther, August 19, 2015, 05:29:26 PM

Previous topic - Next topic

hartrock

Quote from: "Lutz"After doing a few more benchmarks, I stay with append, which is faster when appending more than a few strings. In the save case you have at least about 30 strings of about 72 characters each. extend does a realloc() on each string, while append allocates memory in bigger chunks.

One thought (without looking into interpreter source): extend could reallocate similar as append allocates...

And some questions:

Is append the preferred variant, if special properties of extent like being able to change contents of a literal string inside a lambda are not needed?

Until now I've thought, that extent could be faster for appending one chunk after each other at the end of an empty start string (e.g. for JSON generation); now I think using append wherever possible could be faster.

Is it generally - if special features of extent are not needed - in streaming cases (after initing by (set 'res "")) better to do:

(set 'res (append res arg)) ; many times
instead of:

(extend res arg) ; many times
?

hartrock

#16
Quote from: "Lutz"save strings longer than 2047 will now be broken up in portions of up to 72 characters delimited by normal quotes "..." and escaped for unprintable characters.

Quote from: "Lutz"http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/

I've gotten a backtrace for

  newlisp-10.6.4.tgz  2015-09-09 20:27

:
sr@free:~/newLISP/Inspector$ ~/newLISP_Git/mirror/newlisp inspector.lsp
[log][inspector.lsp Libs:module-opt-overwrite][Info] "/home/sr/newLISP/modules/getopts_patched_Ted.lsp" to be loaded.
[log][inspector.lsp Libs:load-lib][Info] load lib for context WS, depth: 1
[log][inspector.lsp Libs:module-opt-overwrite][Info] "/home/sr/newLISP/lib/WS.lsp" to be loaded.
[log][inspector.lsp Libs:load-lib][Info] load lib for context assert, depth: 2
[log][inspector.lsp Libs:module-opt-overwrite][Info] "/home/sr/newLISP/lib/assert.lsp" to be loaded.
[dbg][inspector.lsp] (assert.lsp...
[log][inspector.lsp Libs:load-lib][Info] load lib for context navi, depth: 3
[log][inspector.lsp Libs:module-opt-overwrite][Info] "/home/sr/newLISP/lib/navi.lsp" to be loaded.
[dbg][inspector.lsp]   (navi.lsp...
[log][inspector.lsp Libs:load-lib][Info] load lib for context assert, depth: 4
[log][inspector.lsp Libs:load-lib][Info] lib 'assert' already seen: skipped.
[log][inspector.lsp Libs:load-lib][Info] load lib for context util, depth: 4
[log][inspector.lsp Libs:module-opt-overwrite][Info] "/home/sr/newLISP/lib/util.lsp" to be loaded.
[dbg][inspector.lsp]     (util.lsp...
[dbg][inspector.lsp]     ...util.lsp)
[dbg][inspector.lsp]   ...navi.lsp)
[log][inspector.lsp Libs:load-lib][Info] load lib for context algo, depth: 3
[log][inspector.lsp Libs:module-opt-overwrite][Info] "/home/sr/newLISP/lib/algo.lsp" to be loaded.
[dbg][inspector.lsp]   (algo.lsp...
[dbg][inspector.lsp]   ...algo.lsp)
[log][inspector.lsp Libs:load-lib][Info] load lib for context util, depth: 3
[log][inspector.lsp Libs:load-lib][Info] lib 'util' already seen: skipped.
[log][inspector.lsp Libs:load-lib][Info] load lib for context tweak, depth: 3
[log][inspector.lsp Libs:module-opt-overwrite][Info] "/home/sr/newLISP/lib/tweak.lsp" to be loaded.
[dbg][inspector.lsp]   (tweak.lsp...
[log][inspector.lsp Libs:load-lib][Info] load lib for context assert, depth: 4
[log][inspector.lsp Libs:load-lib][Info] lib 'assert' already seen: skipped.
[dbg][inspector.lsp]   ...tweak.lsp)
[dbg][inspector.lsp] ...assert.lsp)
[log][inspector.lsp Libs:load-lib][Info] load lib for context FM, depth: 2
[log][inspector.lsp Libs:module-opt-overwrite][Info] "/home/sr/newLISP/lib/FM.lsp" to be loaded.
[dbg][inspector.lsp] (FM.lsp...
[log][inspector.lsp Libs:load-lib][Info] load lib for context assert, depth: 3
[log][inspector.lsp Libs:load-lib][Info] lib 'assert' already seen: skipped.
[log][inspector.lsp Libs:module-opt-overwrite][Info] "/home/sr/newLISP/modules/FOOPReference.lsp" to be loaded.
[dbg][inspector.lsp] ...FM.lsp)
[log][inspector.lsp Libs:load-libs][Info] Trying to initialize lib FM...
[dbg][inspector.lsp] (FM:initialize...
[dbg][inspector.lsp]   ((context FM, symsFromCtx assert)...
[dbg][inspector.lsp tweak:context]  4 (assert) calls modified in: FM
[dbg][inspector.lsp]   ...(context FM, symsFromCtx assert))
[dbg][inspector.lsp]   ((context FM, symsFromCtx dbg)...
[dbg][inspector.lsp]   ...(context FM, symsFromCtx dbg))
[dbg][inspector.lsp] ...FM:initialize)
[log][inspector.lsp Libs:load-libs][Info] ...FM:initialize done.
[log][inspector.lsp Libs:load-libs][Info] Trying to initialize lib tweak...
[dbg][inspector.lsp] (tweak:initialize...
[dbg][inspector.lsp tweak:initialize] nothing to tweak
[dbg][inspector.lsp] ...tweak:initialize)
[log][inspector.lsp Libs:load-libs][Info] ...tweak:initialize done.
[log][inspector.lsp Libs:load-libs][Info] Trying to initialize lib algo...
[log][inspector.lsp Libs:load-libs][Info] ...no algo:initialize found (OK).
[log][inspector.lsp Libs:load-libs][Info] Trying to initialize lib util...
[log][inspector.lsp Libs:load-libs][Info] ...no util:initialize found (OK).
[log][inspector.lsp Libs:load-libs][Info] Trying to initialize lib navi...
[dbg][inspector.lsp] (navi:initialize...
[dbg][inspector.lsp]   ((context navi, symsFromCtx assert)...
[dbg][inspector.lsp tweak:context] 14 (assert:pre) calls modified in: navi
[dbg][inspector.lsp]   ...(context navi, symsFromCtx assert))
[dbg][inspector.lsp]   ((context navi, symsFromCtx dbg)...
[dbg][inspector.lsp tweak:context]  2 (dbg:expr) calls modified in: navi
[dbg][inspector.lsp]   ...(context navi, symsFromCtx dbg))
[dbg][inspector.lsp] ...navi:initialize)
[log][inspector.lsp Libs:load-libs][Info] ...navi:initialize done.
[log][inspector.lsp Libs:load-libs][Info] Trying to initialize lib assert...
[dbg][inspector.lsp] (assert:initialize...
[dbg][inspector.lsp]   ((context assert, symsFromCtx assert)...
[dbg][inspector.lsp tweak:context]  1 (assert:pre) call  modified in: assert
[dbg][inspector.lsp]   ...(context assert, symsFromCtx assert))
[dbg][inspector.lsp]   ((context assert, symsFromCtx dbg)...
[dbg][inspector.lsp]   ...(context assert, symsFromCtx dbg))
[dbg][inspector.lsp] ...assert:initialize)
[log][inspector.lsp Libs:load-libs][Info] ...assert:initialize done.
[log][inspector.lsp Libs:load-libs][Info] Trying to initialize lib WS...
[log][inspector.lsp Libs:load-libs][Info] ...no WS:initialize found (OK).
[dbg][inspector.lsp] (append Inspector:dir "/" Inspector:file) -> "/home/sr/newLISP/Inspector/symbols.html"
[dbg][inspector.lsp] (append Inspector:dir "/" Inspector:file) -> "/home/sr/newLISP/Inspector/jquery-2.1.4.js"
[dbg][inspector.lsp] (append Inspector:dir "/" Inspector:file) -> "/home/sr/newLISP/Inspector/tree.jquery.js"
[dbg][inspector.lsp] (append Inspector:dir "/" Inspector:file) -> "/home/sr/newLISP/Inspector/egBase.js"
[dbg][inspector.lsp] (append Inspector:dir "/" Inspector:file) -> "/home/sr/newLISP/Inspector/symbols.js"
[dbg][inspector.lsp] (append Inspector:dir "/" Inspector:file) -> "/home/sr/newLISP/Inspector/inspector.css"
[dbg][inspector.lsp] (append Inspector:dir "/" Inspector:file) -> "/home/sr/newLISP/Inspector/jqtree.css"
[log][inspector.lsp][Info] {
  "type": "string",
  "length": 3,
  "rep": ""foo""
}
[log][inspector.lsp][Info] {
  "type": "string",
  "length": 3,
  "rep": ""foo""
}
[dbg][inspector.lsp] (Inspector:json-str logg) -> "{
  "type": "context",
  "term": "Logger_1",
  "default": true
}"
[dbg][inspector.lsp] (Inspector:json-expr logg) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "logg",
  "global?": true, "protected?": false,
  "val": {
    "type": "context",
    "term": "Logger_1",
    "default": true
  }
}"
[dbg][inspector.lsp] (Inspector:json-expr +) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "+",
  "global?": true, "protected?": true,
  "val": { "type": "primitive", "val": "+@41CEE0" }
}"
[dbg][inspector.lsp] (Inspector:json-expr 4711) -> "{ "type": "integer", "val": "4711" }"
[dbg][inspector.lsp] (Inspector:json-expr 'MAIN:foo) -> "{ "type": "quote", "val": "'MAIN:foo" }"
[dbg][inspector.lsp] (Inspector:json-str 'MAIN:foo) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "foo",
  "global?": false, "protected?": false,
  "val": {
    "type": "string",
    "length": 3,
    "rep": ""bar""
  }
}"
[dbg][inspector.lsp] (Inspector:json-str 'MAIN:bar) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "bar",
  "global?": false, "protected?": false,
  "val": { "type": "nil", "val": "nil" }
}"
[dbg][inspector.lsp] (Inspector:json-str (array 6 '(1 2 3))) -> "{
  "type": "array",
  "length": 6,
  "rep": "(1 2 3 1 2 3)"
}"
[dbg][inspector.lsp] (Inspector:json-str nil) -> "{ "type": "nil", "val": "nil" }"
[dbg][inspector.lsp] (Inspector:json-str 'nil) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "nil",
  "global?": true, "protected?": true,
  "val": { "type": "nil", "val": "nil" }
}"
[dbg][inspector.lsp] (Inspector:json-str default) -> "{ "type": "primitive", "val": "default@40D140" }"
[dbg][inspector.lsp] (Inspector:json-str 'default) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "default",
  "global?": true, "protected?": true,
  "val": { "type": "primitive", "val": "default@40D140" }
}"
[dbg][inspector.lsp] (Inspector:json-str logg) -> "{
  "type": "context",
  "term": "Logger_1",
  "default": true
}"
[dbg][inspector.lsp] (Inspector:json-str 'logg) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "logg",
  "global?": true, "protected?": false,
  "val": {
    "type": "context",
    "term": "Logger_1",
    "default": true
  }
}"
[dbg][inspector.lsp] (Inspector:json-str MAIN) -> "{
  "type": "context",
  "term": "MAIN",
  "default": true
}"
[dbg][inspector.lsp] (Inspector:json-str 'MAIN) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "MAIN",
  "global?": true, "protected?": true,
  "val": {
    "type": "context",
    "term": "MAIN",
    "default": true
  }
}"
[dbg][inspector.lsp] (Inspector:json-str true) -> "{ "type": "true", "val": "true" }"
[dbg][inspector.lsp] (Inspector:json-str 'true) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "true",
  "global?": true, "protected?": true,
  "val": { "type": "true", "val": "true" }
}"
[dbg][inspector.lsp] (Inspector:json-str "foo "bar" buz") -> "{
  "type": "string",
  "length": 13,
  "rep": ""foo \"bar\" buz""
}"
*** glibc detected *** /home/sr/newLISP_Git/mirror/newlisp: double free or corruption (fasttop): 0x0000000000a2ea20 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x75be6)[0x7fc1f50b9be6]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7fc1f50be98c]
/home/sr/newLISP_Git/mirror/newlisp[0x4082e1]
/home/sr/newLISP_Git/mirror/newlisp[0x412ecb]
/home/sr/newLISP_Git/mirror/newlisp[0x41315b]
/home/sr/newLISP_Git/mirror/newlisp[0x413226]
/home/sr/newLISP_Git/mirror/newlisp[0x40b765]
/home/sr/newLISP_Git/mirror/newlisp[0x410435]
/home/sr/newLISP_Git/mirror/newlisp[0x41062a]
/home/sr/newLISP_Git/mirror/newlisp[0x4136f2]
/home/sr/newLISP_Git/mirror/newlisp[0x40b765]
/home/sr/newLISP_Git/mirror/newlisp[0x410435]
/home/sr/newLISP_Git/mirror/newlisp[0x41062a]
/home/sr/newLISP_Git/mirror/newlisp[0x407482]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd)[0x7fc1f5062ead]
/home/sr/newLISP_Git/mirror/newlisp[0x407575]
======= Memory map: ========
00400000-00454000 r-xp 00000000 08:01 4671427                            /home/sr/newLISP_Git/mirror/newlisp
00654000-00658000 rw-p 00054000 08:01 4671427                            /home/sr/newLISP_Git/mirror/newlisp
00658000-0065b000 rw-p 00000000 00:00 0
009f8000-00aa9000 rw-p 00000000 00:00 0                                  [heap]
7fc1f0000000-7fc1f0021000 rw-p 00000000 00:00 0
7fc1f0021000-7fc1f4000000 ---p 00000000 00:00 0
7fc1f47c3000-7fc1f47d8000 r-xp 00000000 08:01 1941506                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc1f47d8000-7fc1f49d8000 ---p 00015000 08:01 1941506                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc1f49d8000-7fc1f49d9000 rw-p 00015000 08:01 1941506                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc1f49d9000-7fc1f4a5c000 rw-p 00000000 00:00 0
7fc1f4a5c000-7fc1f4e1b000 r--p 00000000 08:01 3489798                    /usr/lib/locale/locale-archive
7fc1f4e1b000-7fc1f4e40000 r-xp 00000000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fc1f4e40000-7fc1f503f000 ---p 00025000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fc1f503f000-7fc1f5043000 r--p 00024000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fc1f5043000-7fc1f5044000 rw-p 00028000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fc1f5044000-7fc1f51c5000 r-xp 00000000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7fc1f51c5000-7fc1f53c5000 ---p 00181000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7fc1f53c5000-7fc1f53c9000 r--p 00181000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7fc1f53c9000-7fc1f53ca000 rw-p 00185000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7fc1f53ca000-7fc1f53cf000 rw-p 00000000 00:00 0
7fc1f53cf000-7fc1f53db000 r-xp 00000000 08:01 1974305                    /usr/lib/x86_64-linux-gnu/libffi.so.5.0.10
7fc1f53db000-7fc1f55db000 ---p 0000c000 08:01 1974305                    /usr/lib/x86_64-linux-gnu/libffi.so.5.0.10
7fc1f55db000-7fc1f55dc000 rw-p 0000c000 08:01 1974305                    /usr/lib/x86_64-linux-gnu/libffi.so.5.0.10
7fc1f55dc000-7fc1f5619000 r-xp 00000000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7fc1f5619000-7fc1f5819000 ---p 0003d000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7fc1f5819000-7fc1f581b000 r--p 0003d000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7fc1f581b000-7fc1f5821000 rw-p 0003f000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7fc1f5821000-7fc1f5823000 rw-p 00000000 00:00 0
7fc1f5823000-7fc1f5825000 r-xp 00000000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7fc1f5825000-7fc1f5a25000 ---p 00002000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7fc1f5a25000-7fc1f5a26000 r--p 00002000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7fc1f5a26000-7fc1f5a27000 rw-p 00003000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7fc1f5a27000-7fc1f5aa8000 r-xp 00000000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7fc1f5aa8000-7fc1f5ca7000 ---p 00081000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7fc1f5ca7000-7fc1f5ca8000 r--p 00080000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7fc1f5ca8000-7fc1f5ca9000 rw-p 00081000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7fc1f5ca9000-7fc1f5cc9000 r-xp 00000000 08:01 4423706                    /lib/x86_64-linux-gnu/ld-2.13.so
7fc1f5da8000-7fc1f5de5000 rw-p 00000000 00:00 0
7fc1f5e5f000-7fc1f5ea6000 rw-p 00000000 00:00 0
7fc1f5ec6000-7fc1f5ec8000 rw-p 00000000 00:00 0
7fc1f5ec8000-7fc1f5ec9000 r--p 0001f000 08:01 4423706                    /lib/x86_64-linux-gnu/ld-2.13.so
7fc1f5ec9000-7fc1f5eca000 rw-p 00020000 08:01 4423706                    /lib/x86_64-linux-gnu/ld-2.13.so
7fc1f5eca000-7fc1f5ecb000 rw-p 00000000 00:00 0
7ffeaab64000-7ffeaab85000 rw-p 00000000 00:00 0                          [stack]
7ffeaab94000-7ffeaab95000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted
sr@free:~/newLISP/Inspector$ uname -a
Linux free 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u3 x86_64 GNU/Linux

@Lutz:

What about an extra forum for errors in the inprogress version? Would be easy to track for you, and after a fix nobody cares.

Or?

Lutz

extend is destructive append is not. Many things in newLISP can be done in either a destructive or non-destructive manner and destructive functions are marked with an ! in the reference.



http://www.newlisp.org/downloads/newlisp_manual.html#destructive">http://www.newlisp.org/downloads/newlis ... estructive">http://www.newlisp.org/downloads/newlisp_manual.html#destructive



Most destructive functions - like extend too - can also do in-place modification. See the last sub-chapter about this on this page: http://www.newlisp.org/index.cgi?page=Closures">http://www.newlisp.org/index.cgi?page=Closures



Bench-marking is a tricky business you can find some benchmarks comparing to Perl and Python here: http://newlisp.nfshost.com/benchmarks/">http://newlisp.nfshost.com/benchmarks/

Small changes how a function is used may cause big differences in benchmarks. Sometimes just moving between OSs or versions of compilers changes everything. That is, why I like the benchmarks in the link, because they always measure function performance in an application context.



ps: people report errors under all topics of the forum,  and that has worked well in the passed times.

hartrock

Quote from: "Lutz"
ps: people report errors under all topics of the forum,  and that has worked well in the passed times.

Does this kind of backtrace help you, or do you need more or less info?

hartrock

Quote from: "Lutz"extend is destructive append is not. Many things in newLISP can be done in either a destructive or non-destructive manner and destructive functions are marked with an ! in the reference.



http://www.newlisp.org/downloads/newlisp_manual.html#destructive">http://www.newlisp.org/downloads/newlis ... estructive">http://www.newlisp.org/downloads/newlisp_manual.html#destructive



Most destructive functions - like extend too - can also do in-place modification. See the last sub-chapter about this on this page: http://www.newlisp.org/index.cgi?page=Closures">http://www.newlisp.org/index.cgi?page=Closures



Bench-marking is a tricky business

...

Normally I don't like to think about performance: if there are only small differences in performance, I'd always prefer the more elegant - mostly the shorter - solution.

In this sense

(extend res arg) ; many times
surely is better than

(set 'res (append res arg)) ; many times
.

But sometimes some inner workings of a language implementation are bubbling up in form of surprises to the programmer not being aware of them: I'm remembering my trial to get away some asymmetries regarding push/pop, while ignoring the inner structure of lists (which is the reason for them)...

xytroxon

While being destructive, the extend function also has variable history to worry about! To use the extend function in the save output to avoid side effects when executing the load function, res MUST be explicitly RESET to nil or "the empty string" to prevent seemingly random "string errors" from occuring if the res variable had been set before. (Like in a third party module or from executing load multiple times from the REPL terminal.)



;... earlier executed code
(++ res) ;-> error [1]
; or
(set 'res '("John Doe" "1234 Main St" "Any Town, USA")) ;-> error [2]
; or
(set 'res "{string that remains from the first load}") ;-> error [3]

; ...when load is executed

(extend res arg1 arg2 arg3 ...)

; Code fails if res previously contained [1] a number, or "works" and extends either [2] a list, or [3] a string!


So the code generated by the save function would need to be:



(set 'res "") ; clear string
(extend res arg1 arg2 arg3 ...)


As per the norm, the Lutz version is optimal, (if not always beautiful) ;o)



-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976

hartrock

Quote from: "xytroxon"
So the code generated by the save function would need to be:



(set 'res "") ; clear string
(extend res arg1 arg2 arg3 ...)


Sure.

Usecase in mind has been streaming: see http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=16&t=4743#p23412">//http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=16&t=4743#p23412, where the init to an empty string at the beginning has been mentioned, too.

Possibly it had been better to repeat more accurate, without expecting knowledge about all of this very long thread.

hartrock

#22
Tested with changed inprogress version backtrace again:

[dbg][inspector.lsp] (Inspector:json-str 'true) -> "{
  "type": "sym",
  "prefix": "MAIN", "term": "true",
  "global?": true, "protected?": true,
  "val": { "type": "true", "val": "true" }
}"
[dbg][inspector.lsp] (Inspector:json-str "foo "bar" buz") -> "{
  "type": "string",
  "length": 13,
  "rep": ""foo \"bar\" buz""
}"
*** glibc detected *** /home/sr/newLISP_Git/mirror/newlisp: double free or corruption (fasttop): 0x0000000001f824e0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x75be6)[0x7f21d33c9be6]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7f21d33ce98c]
/home/sr/newLISP_Git/mirror/newlisp[0x4082e1]
/home/sr/newLISP_Git/mirror/newlisp[0x412ecb]
/home/sr/newLISP_Git/mirror/newlisp[0x41315b]
/home/sr/newLISP_Git/mirror/newlisp[0x413226]
/home/sr/newLISP_Git/mirror/newlisp[0x40b765]
/home/sr/newLISP_Git/mirror/newlisp[0x410435]
/home/sr/newLISP_Git/mirror/newlisp[0x41062a]
/home/sr/newLISP_Git/mirror/newlisp[0x4136f2]
/home/sr/newLISP_Git/mirror/newlisp[0x40b765]
/home/sr/newLISP_Git/mirror/newlisp[0x410435]
/home/sr/newLISP_Git/mirror/newlisp[0x41062a]
/home/sr/newLISP_Git/mirror/newlisp[0x407482]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd)[0x7f21d3372ead]
/home/sr/newLISP_Git/mirror/newlisp[0x407575]
======= Memory map: ========
00400000-00454000 r-xp 00000000 08:01 4671433                            /home/sr/newLISP_Git/mirror/newlisp
00654000-00658000 rw-p 00054000 08:01 4671433                            /home/sr/newLISP_Git/mirror/newlisp
00658000-0065b000 rw-p 00000000 00:00 0
01f4c000-01ffd000 rw-p 00000000 00:00 0                                  [heap]
7f21cc000000-7f21cc021000 rw-p 00000000 00:00 0
7f21cc021000-7f21d0000000 ---p 00000000 00:00 0
7f21d2ad3000-7f21d2ae8000 r-xp 00000000 08:01 1941506                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f21d2ae8000-7f21d2ce8000 ---p 00015000 08:01 1941506                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f21d2ce8000-7f21d2ce9000 rw-p 00015000 08:01 1941506                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f21d2ce9000-7f21d2d6c000 rw-p 00000000 00:00 0
7f21d2d6c000-7f21d312b000 r--p 00000000 08:01 3489798                    /usr/lib/locale/locale-archive
7f21d312b000-7f21d3150000 r-xp 00000000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f21d3150000-7f21d334f000 ---p 00025000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f21d334f000-7f21d3353000 r--p 00024000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f21d3353000-7f21d3354000 rw-p 00028000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f21d3354000-7f21d34d5000 r-xp 00000000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7f21d34d5000-7f21d36d5000 ---p 00181000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7f21d36d5000-7f21d36d9000 r--p 00181000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7f21d36d9000-7f21d36da000 rw-p 00185000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7f21d36da000-7f21d36df000 rw-p 00000000 00:00 0
7f21d36df000-7f21d36eb000 r-xp 00000000 08:01 1974305                    /usr/lib/x86_64-linux-gnu/libffi.so.5.0.10
7f21d36eb000-7f21d38eb000 ---p 0000c000 08:01 1974305                    /usr/lib/x86_64-linux-gnu/libffi.so.5.0.10
7f21d38eb000-7f21d38ec000 rw-p 0000c000 08:01 1974305                    /usr/lib/x86_64-linux-gnu/libffi.so.5.0.10
7f21d38ec000-7f21d3929000 r-xp 00000000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7f21d3929000-7f21d3b29000 ---p 0003d000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7f21d3b29000-7f21d3b2b000 r--p 0003d000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7f21d3b2b000-7f21d3b31000 rw-p 0003f000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7f21d3b31000-7f21d3b33000 rw-p 00000000 00:00 0
7f21d3b33000-7f21d3b35000 r-xp 00000000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7f21d3b35000-7f21d3d35000 ---p 00002000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7f21d3d35000-7f21d3d36000 r--p 00002000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7f21d3d36000-7f21d3d37000 rw-p 00003000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7f21d3d37000-7f21d3db8000 r-xp 00000000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7f21d3db8000-7f21d3fb7000 ---p 00081000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7f21d3fb7000-7f21d3fb8000 r--p 00080000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7f21d3fb8000-7f21d3fb9000 rw-p 00081000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7f21d3fb9000-7f21d3fd9000 r-xp 00000000 08:01 4423706                    /lib/x86_64-linux-gnu/ld-2.13.so
7f21d40b8000-7f21d40f5000 rw-p 00000000 00:00 0
7f21d416f000-7f21d41b6000 rw-p 00000000 00:00 0
7f21d41d6000-7f21d41d8000 rw-p 00000000 00:00 0
7f21d41d8000-7f21d41d9000 r--p 0001f000 08:01 4423706                    /lib/x86_64-linux-gnu/ld-2.13.so
7f21d41d9000-7f21d41da000 rw-p 00020000 08:01 4423706                    /lib/x86_64-linux-gnu/ld-2.13.so
7f21d41da000-7f21d41db000 rw-p 00000000 00:00 0
7ffd68a28000-7ffd68a49000 rw-p 00000000 00:00 0                          [stack]
7ffd68ab1000-7ffd68ab2000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted
sr@free:~/newLISP/Inspector$

Lutz

Try to boil down the code to the least amount needed to produce the error. Back-tracing does not help here.

hartrock

Quote from: "Lutz"Try to boil down the code to the least amount needed to produce the error. Back-tracing does not help here.

OK.

Problem seems to be related to strings:

sr@free:~/newLISP_Git/mirror$ ./newlisp
newLISP v.10.6.4 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

> (set 's "foo bar buz" 'r "")
""
> (time (extend r s) 200)
0.07000000000000001
> (source 'r) ; -> boom!
*** glibc detected *** ./newlisp: double free or corruption (fasttop): 0x000000000114bb60 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x75be6)[0x7fc73176bbe6]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7fc73177098c]
./newlisp[0x4082e1]
./newlisp[0x412ecb]
./newlisp[0x41315b]
./newlisp[0x4253dd]
./newlisp[0x40b765]
./newlisp[0x410435]
./newlisp[0x410aca]
./newlisp[0x406ede]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd)[0x7fc731714ead]
./newlisp[0x407575]
======= Memory map: ========
00400000-00454000 r-xp 00000000 08:01 4671433                            /home/sr/newLISP_Git/mirror/newlisp
00654000-00658000 rw-p 00054000 08:01 4671433                            /home/sr/newLISP_Git/mirror/newlisp
00658000-0065b000 rw-p 00000000 00:00 0
010c8000-0115c000 rw-p 00000000 00:00 0                                  [heap]
7fc72c000000-7fc72c021000 rw-p 00000000 00:00 0
7fc72c021000-7fc730000000 ---p 00000000 00:00 0
7fc730e75000-7fc730e8a000 r-xp 00000000 08:01 1941506                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc730e8a000-7fc73108a000 ---p 00015000 08:01 1941506                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc73108a000-7fc73108b000 rw-p 00015000 08:01 1941506                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fc73108b000-7fc7310cd000 rw-p 00000000 00:00 0
7fc73110e000-7fc7314cd000 r--p 00000000 08:01 3489798                    /usr/lib/locale/locale-archive
7fc7314cd000-7fc7314f2000 r-xp 00000000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fc7314f2000-7fc7316f1000 ---p 00025000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fc7316f1000-7fc7316f5000 r--p 00024000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fc7316f5000-7fc7316f6000 rw-p 00028000 08:01 4424152                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fc7316f6000-7fc731877000 r-xp 00000000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7fc731877000-7fc731a77000 ---p 00181000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7fc731a77000-7fc731a7b000 r--p 00181000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7fc731a7b000-7fc731a7c000 rw-p 00185000 08:01 4423693                    /lib/x86_64-linux-gnu/libc-2.13.so
7fc731a7c000-7fc731a81000 rw-p 00000000 00:00 0
7fc731a81000-7fc731a8d000 r-xp 00000000 08:01 1974305                    /usr/lib/x86_64-linux-gnu/libffi.so.5.0.10
7fc731a8d000-7fc731c8d000 ---p 0000c000 08:01 1974305                    /usr/lib/x86_64-linux-gnu/libffi.so.5.0.10
7fc731c8d000-7fc731c8e000 rw-p 0000c000 08:01 1974305                    /usr/lib/x86_64-linux-gnu/libffi.so.5.0.10
7fc731c8e000-7fc731ccb000 r-xp 00000000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7fc731ccb000-7fc731ecb000 ---p 0003d000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7fc731ecb000-7fc731ecd000 r--p 0003d000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7fc731ecd000-7fc731ed3000 rw-p 0003f000 08:01 1941596                    /lib/x86_64-linux-gnu/libreadline.so.6.2
7fc731ed3000-7fc731ed5000 rw-p 00000000 00:00 0
7fc731ed5000-7fc731ed7000 r-xp 00000000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7fc731ed7000-7fc7320d7000 ---p 00002000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7fc7320d7000-7fc7320d8000 r--p 00002000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7fc7320d8000-7fc7320d9000 rw-p 00003000 08:01 4423699                    /lib/x86_64-linux-gnu/libdl-2.13.so
7fc7320d9000-7fc73215a000 r-xp 00000000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7fc73215a000-7fc732359000 ---p 00081000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7fc732359000-7fc73235a000 r--p 00080000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7fc73235a000-7fc73235b000 rw-p 00081000 08:01 4423686                    /lib/x86_64-linux-gnu/libm-2.13.so
7fc73235b000-7fc73237b000 r-xp 00000000 08:01 4423706                    /lib/x86_64-linux-gnu/ld-2.13.so
7fc732553000-7fc732558000 rw-p 00000000 00:00 0
7fc732570000-7fc732577000 r--s 00000000 08:01 3834320                    /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
7fc732577000-7fc73257a000 rw-p 00000000 00:00 0
7fc73257a000-7fc73257b000 r--p 0001f000 08:01 4423706                    /lib/x86_64-linux-gnu/ld-2.13.so
7fc73257b000-7fc73257c000 rw-p 00020000 08:01 4423706                    /lib/x86_64-linux-gnu/ld-2.13.so
7fc73257c000-7fc73257d000 rw-p 00000000 00:00 0
7ffd27859000-7ffd2787a000 rw-p 00000000 00:00 0                          [stack]
7ffd2793e000-7ffd2793f000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted

Lutz

Thanks Hartrock, fixed here:

http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/ 2015-09-11 16:19

hartrock

Thanks Lutz,

working for me.