Code Monkey home page Code Monkey logo

jimtcl's Introduction

The Jim Interpreter

A small-footprint implementation of the Tcl programming language.

--------------------------------------------------------------------------------
WHAT IS JIM?
--------------------------------------------------------------------------------

Jim is a small footprint implementation of the Tcl programming language
written from scratch. Currently Jim Tcl is very feature complete with
an extensive test suite (see the tests directory).
There are some Tcl commands and features which are not implemented
(and likely never will be), including traces and Tk. However,
Jim Tcl offers a number of both Tcl8.5 and Tcl8.6 features ({*}, dict, lassign,
tailcall and optional UTF-8 support) and some unique features.
These unique features include [lambda] with garbage collection, a general GC/references
system, arrays as syntax sugar for [dict]tionaries, object-based I/O and more.

Other common features of the Tcl programming language are present, like
the "everything is a string" behaviour, implemented internally as
dual ported objects to ensure that the execution time does not reflect
the semantic of the language :)

--------------------------------------------------------------------------------
WHEN JIM CAN BE USEFUL?
--------------------------------------------------------------------------------

1) Jim provides the ability to write scriptable applications without needing
to link your application with a big system. You can include the Jim source 
directly in your project and use the Jim API to write the glue code that makes 
your application scriptable in Jim, with the following advantages:

- Jim is not the next "little language", but it's a Tcl implementation.
  You can reuse your knowledge if you already have Tcl skills, or enjoy
  the availability of documentation, books, web resources, ...
  (for example check my online Tcl book at http://www.invece.org/tclwise)

- Jim is simple with 14k lines of core code. If you want to adapt it you can hack
  the source code to meet the needs of your application. It makes you
  able to have scripting by default, and avoid external dependencies.

  Having scripting support *inside*, and in a way that a given version
  of your program always gets shipped with the given version of Jim, you can
  write part of your application in Jim itself. This is similar to Emacs/Elisp
  or Gimp/Scheme, where both of these applications have the interpreter inside. 

- Jim is Tcl, and Tcl looks like a configuration file if you want. So
  if you use Jim you also have a flexible syntax for your config file.
  This is a valid Tcl script:

     set MyFeature on
     ifssl {
       set SslPort 45000
       use compression
     }

  It looks like a configuration file, but if you implement the [ifssl]
  and [use] commands, it's a valid Tcl script.

- Tcl scales with the user. Not all know it, but Tcl is so powerful that
  you can reprogram the language in itself. Jim support this feature
  of the Tcl programming language. You can write new control structures, and
  use the flexible data types it offers (Lists are a central data structure,
  with Dictionaries that are also lists). Still, Tcl is simpler for the
  casual programmer, especially when compared to other languages offering
  small footprint implementations (like Scheme and FORTH).

- Because of the Tcl semantic (pass by value, everything is a command
  since there are no reserved words), there is a nice API to glue
  your application with Jim. See under the Jim Tcl manual for more detail.

- Jim is supported. If you need commercial software, contact the original author
  at '[email protected]' or the current maintainer at '[email protected]'.

2) The other "field" where Jim can be useful is obviously embedded systems.

3) We are working to make Jim as feature-complete as possible. Thanks to
   dynamically loaded extensions it may stay as small as it is today
   but able to do interesting things for you. So it's possible that
   in the future Jim will be an option as a general purpose language.
   But don't worry, there is already the mainstream Tcl implementation
   for this :).

--------------------------------------------------------------------------------
HOW BIG IS IT?
--------------------------------------------------------------------------------

Jim with the default extensions configured and compiled with -Os is about 130k.
Without any extensions, it is about 85k.

--------------------------------------------------------------------------------
HOW FAST IS IT?
--------------------------------------------------------------------------------

Jim is, in most code, faster than Tcl7.6p2 (latest 7.x version),
and slower than Tcl 8.4.x. You can expect pretty decent performance
for such a little interpreter.

If you want a more precise measure, there is 'bench.tcl' inside this
distribution that will run both under Jim and Tcl, so just execute
it with both the interpreters and see what you get :)

--------------------------------------------------------------------------------
HOW TO COMPILE
--------------------------------------------------------------------------------

Jim was tested under Linux, FreeBSD, MacosX, eCos, QNX, Windows XP (mingw, MVC).

To compile Jim itself try:

  ./configure
  make

--------------------------------------------------------------------------------
EXTENSIONS
--------------------------------------------------------------------------------

Many optional extensions are included. Some are C extensions and others are pure Tcl.
Form more information, try:

  ./configure --help

--------------------------------------------------------------------------------
HOW TO EMBED JIM INTO APPLICATIONS
--------------------------------------------------------------------------------

See the "examples.api" directory

--------------------------------------------------------------------------------
HOW TO WRITE EXTENSIONS FOR JIM
--------------------------------------------------------------------------------

See the extensions shipped with Jim, jim-readline.c, jim-clock.c, glob.tcl and oo.tcl

--------------------------------------------------------------------------------
COPYRIGHT and LICENSE
--------------------------------------------------------------------------------

Unless explicitly stated, all files within Jim repository are released
under following license:

/* Jim - A small embeddable Tcl interpreter
 *
 * Copyright 2005 Salvatore Sanfilippo <[email protected]>
 * Copyright 2005 Clemens Hintze <[email protected]>
 * Copyright 2005 patthoyts - Pat Thoyts <[email protected]>
 * Copyright 2008 oharboe - Øyvind Harboe - [email protected]
 * Copyright 2008 Andrew Lunn <[email protected]>
 * Copyright 2008 Duane Ellis <[email protected]>
 * Copyright 2008 Uwe Klein <[email protected]>
 * Copyright 2008 Steve Bennett <[email protected]>
 * Copyright 2009 Nico Coesel <[email protected]>
 * Copyright 2009 Zachary T Welch [email protected]
 * Copyright 2009 David Brownell
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above
 *    copyright notice, this list of conditions and the following
 *    disclaimer in the documentation and/or other materials
 *    provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * The views and conclusions contained in the software and documentation
 * are those of the authors and should not be interpreted as representing
 * official policies, either expressed or implied, of the Jim Tcl Project.
 */
--------------------------------------------------------------------------------
HISTORY
--------------------------------------------------------------------------------

"first Jim goal: to vent my need to hack on Tcl."

And actually this is exactly why I started Jim, in the first days
of January 2005. After a month of hacking Jim was able to run
simple scripts, now, after two months it started to be clear to
me that it was not just the next toy to throw away but something
that may evolve into a real interpreter. In the same time
Pat Thoyts and Clemens Hintze started to contribute code, so that
the development of new core commands was faster, and also more
people hacking on the same code had as result fixes in the API,
C macros, and so on.

Currently we are at the point that the core interpreter is almost finished
and it is entering the Beta stage. There is to add some other core command,
to do a code review to ensure quality of all the parts and to write
documentation.

We already started to work on extensions like OOP, event loop,
I/O, networking, regexp. Some extensions are already ready for
prime time, like the Sqlite extension and the ANSI I/O.

------------------------------------------------------------------------------
Thanks to...
------------------------------------------------------------------------------

- First of all, thanks to every guy that are listed in the AUTHORS file,
  that directly helped with code and ideas. Also check the ChangeLog
  file for additional credits about patches or bug reports.
- Elisa Manara that helped me to select this ill conceived name for
  an interpreter.
- Many people on the Tclers Chat that helped me to explore issues
  about the use and the implementation of the Tcl programming language.
- David Welton for the tech info sharing and our chats about
  programming languages design and the ability of software to "scale down".
- Martin S. Weber for the great help with Solaris issues, debugging of
  problems with [load] on this arch, 64bit tests.
- The authors of "valgrind", for this wonderful tool, that helped me a
  lot to fix bugs in minutes instead of hours.


----
Enjoy!
Salvatore Sanfilippo
10 Mar 2005


jimtcl's People

Contributors

alexshpilkin avatar b4yuan avatar borneoa avatar broadcom-wiced-admin avatar clbr avatar dbohdan avatar dimkr avatar edgargrimberg avatar evanhunter avatar ezequielgarcia avatar ffainelli avatar ffontaine avatar gahr avatar hummypkg avatar incanus avatar jiez-adi avatar marrero avatar mistachkin avatar mrv96 avatar msteveb avatar nborodikhin avatar ntfreak avatar oharboe avatar oskaritimperi avatar paulfertser avatar prpr19xx avatar syed-naufal-mahmood avatar the-markitecht avatar vadim-z avatar vkremneva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jimtcl's Issues

Parser ignores missing "]" in [commands]

The parser ignores a missing "]" in e.g.:

$>./jimsh -e "puts [string length test"
4

and

$>./jimsh -e "if { [string length test } { puts -nonewline ok }"
ok

and

$>echo "if { [string length test } { puts -nonewline ok }" > test.tcl
$>jimsh test.tcl 
ok

whereas

$>echo "puts [string length test" > test.tcl
$>jimsh test.tcl 
Runtime Error: tree.tcl:6: unmatched "[" in "test.tcl" at line 1
at file "tree.tcl", line 6

reports the expected error.

Btw: the function prototype for JimParseSubCmd() is declared twice in jim.c

Mysql support

Is there some plan to support MySQL database in the future?

Building out-of-tree

I have found that the following build sequence fails:

./configure && make
mkdir build2
cd build2
../configure && make

This appears to be due to VPATH confusing the make system and causing it to partially find jimsh.o in the in-tree source directory even when building out-of-tree.

Replacing the VPATH statement with the following seems to fix it:
vpath %.h ..
vpath %.c ..
vpath %.tcl ..

i.e. only search for sources in the source directory - not objects/libs

Regards,

Evan

tclcompat.tcl: file copy minor issue

Hi

This command in Tcl does not touch origin

% file copy -force origin origin

and this one (in Jim Tcl) does truncate origin

. file copy -force origin origin

If you have no objections tclcomapt.tcl.patch. Sorry for mess with the patch here but I could not subscribe to jim-devel list. Does mailman reject gmail?

zlib segfault

% zlib gzip a
Will segfault for me on OpenBSD.
This patch fixes the segfault but now I get an empty error message.
Tcl's zlib code is a bit more elaborate where Z_FINISH is concerned.

--- jim-zlib.c.orig     Mon Apr 17 10:37:32 2017
+++ jim-zlib.c  Mon Apr 17 10:38:03 2017
@@ -98,7 +98,7 @@ static int Jim_Compress(Jim_Interp *interp, const char
      * decompressed data anyway, so there's no reason to do chunked
      * decompression */
     if (deflate(&strm, Z_FINISH) != Z_STREAM_END) {
-        Jim_Free(strm.next_out);
+        Jim_Free(buf);
         deflateEnd(&strm);
         return JIM_ERR;
     }
@@ -106,7 +106,7 @@ static int Jim_Compress(Jim_Interp *interp, const char
     deflateEnd(&strm);
 
     if (strm.total_out > INT_MAX) {
-        Jim_Free(strm.next_out);
+        Jim_Free(buf);
         return JIM_ERR;
     }

Compile error with C89 compiler

'
jim-tclprefix.c: In function Jim_TclPrefixCoreCommand': jim-tclprefix.c:163: parse error before int'
jim-tclprefix.c:165: i' undeclared (first use in this function) jim-tclprefix.c:165: (Each undeclared identifier is reported only once jim-tclprefix.c:165: for each function it appears in.) jim-tclprefix.c:165: listlen' undeclared (first use in this function)
make[1]: *** [jim-tclprefix.o] Error 1
'

Local variables 'i' and 'listen' are declared in the middle of the code block (C99-style) which results in compilation error with C89-only compiler.

[package require tcltest] errs due to missing ::argv0

I'm using this patch.

--- tcltest.tcl.orig    Sun Apr  5 00:30:30 2015
+++ tcltest.tcl Sun Apr  5 00:33:45 2015
@@ -9,7 +9,7 @@ set testinfo(numskip) 0
 set testinfo(numtests) 0
 set testinfo(failed) {}

-set testdir [file dirname $::argv0]
+set testdir [file dirname [expr {[info exists ::argv0] ? $::argv0 : $::jim::argv0}]]
 set bindir [file dirname [info nameofexecutable]]

 if {[lsearch $argv "-verbose"] >= 0 || [info exists env(testverbose)]} {

Ideas for how to improve working with byte strings in UTF-8 builds of Jim Tcl

Jim Tcl's built-in support for Unicode is a very useful feature and sets it apart from other embedded interpreters like pre-5.3 Lua. However, enabling UTF-8 means that commands like string index will operate on characters and not bytes, so the user has to choose between UTF-8 and being able to handle byte strings as easily as in "big" Tcl. I don't know how much this limitation affects other users of Jim Tcl, but it has caused me some problems, most noticeably when I was writing a JPEG decoder. I am opening this issue as a place to aggregate and discuss the possible ways to improve Jim's ability to handle both byte and UTF-8 strings in the same build.

I see three major ways to do it, each with its own drawbacks:

  1. Make strings work like in Tcl 8.x (downsides: the required effort, new core code, changes to the internal representation, harder to make optional — seems like a no-go);
  2. Add commands to escape and unescape binary data as suggested in README.utf-8 (downside: the user will have to keep track of escaping and unescaping data);
  3. Add new specialized subcommands, e.g., string byteindex and string byterange like string bytelength (downside: different from Tcl 8.x and feels ad hoc).

What do you think?

Tests involving [exec program >> file] fail on MSYS2/MinGW-w64

This is a separate issue for the bug I found in #57.

Each of the failed tests involves [exec] appending the output of a command to a file. E.g. (this is the MSYS2 shell),

$ ./jimsh.exe -e 'exec echo "First line" >> new.file' && cat new.file
/usr/bin/echo: write error: Bad file descriptor

However, the > redirect works:

$ ./jimsh.exe -e 'exec echo "First line" > new.file' && cat new.file

First line

Segmentation Faults 2017-05-25

Hello,
I was using American Fuzzy Lop (afl-fuzz) to fuzz input the jimsh program. Is fixing the crashes from these input files something you're interested in? The input files can be found here: https://github.com/rwhitworth/jimtcl-fuzz/tree/master/2017-05-25.

The files can be executed as ./jimsh id_filename to cause seg faults. They were tested against git commit bd5139c.

Let me know if I can provide any more information to help narrow down this issue.

Also, if you're tired of these reports let me know and I'll cease. I understand this sort of report can be frustrating.

Cannot compile bootstrap version on MinGW 4.5.1

Hi!

I can't compile the bootstrap version of jim on MinGW 4.5.1 due to the strtod define in jim-win32compat.h made in 92aaf45. The compiler gives the following errors:

In file included from jimsh0.c:177:0:
d:\dev\build-env\mingw-tdm-4.5.1\dw2\bin\../lib/gcc/mingw32/4.5.1-dw2/../../../.
./include/stdlib.h:319:1: error: static declaration of '__strtod' follows non-st
atic declaration
d:\dev\build-env\mingw-tdm-4.5.1\dw2\bin\../lib/gcc/mingw32/4.5.1-dw2/../../../.
./include/stdlib.h:312:32: note: previous declaration of '__strtod' was here

I could get the compilation working by including stdlib.h just before the define.

"Something" regarding exec'd file descriptor handling is incompatible with sqlite3 clients

After updating jimtcl to e62a1bb (from repo.or.cz), when i exec fossil i'm getting a warning from sqlite3 which is mangling my autosetup output:

SQLITE_WARNING(28): attempt to open \"/home/stephan/fossil/cwal/.fslckout\" as file descriptor 0"
...
SQLITE_WARNING(28): attempt to open \"/home/stephan/fossil/cwal/.fslckout\" as file descriptor 0 built 2018-11-22 07:03"

That happens from running exec fossil info. i recall Richard adding that warning to sqlite3 because we had a case in fossil where an assert() caused output to go to file descriptor 0 or 1 and fossil had opened its db with that file descriptor, so the output from assert overwrote a random part of the database file. i don't recall the remaining details.

i suspect, without being certain, that some recent jimtcl change (sometime since v77) is closing FD's during exec, freeing up the ID 0 for re-use in the spawned process. When fossil opens up .fslcheckout, it's getting FD 0, which is a recipe for db corruption.

If i backrev to jimsh version 77, this doesn't happen... but that one is missing the -gmt flag for clock, which was the reason i upgraded to version 78 :/.

stack-overflow in ExprTreeBuildTree

Hello.

I found a stack-overflow bug in jimtcl.

Please confirm.

Thanks.

OS: CentOS 7 64bit
Version: 88c5e1f
PoC Download: ov_ExprTreeBuildTree.zip

Steps to reproduce:
1.Download the .POC files.
2.Compile the source code with ASan.
3.Execute the following command
: ./jimsh $FILE

=================================================================
==11855==ERROR: AddressSanitizer: stack-overflow on address 0x7ffe19053fe0 (pc 0x000000572269 bp 0x7ffe19054150 sp 0x7ffe19053fe0 T0)
    #0 0x572268 in ExprTreeBuildTree /home/karas/jimtcl/jim.c:8827
    #1 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #2 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #3 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #4 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #5 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #6 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #7 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #8 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #9 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #10 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #11 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #12 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #13 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #14 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #15 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #16 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #17 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #18 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #19 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #20 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #21 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #22 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #23 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #24 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #25 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #26 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #27 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #28 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #29 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #30 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #31 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #32 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #33 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #34 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #35 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #36 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #37 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #38 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #39 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #40 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #41 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #42 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #43 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #44 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #45 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #46 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #47 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #48 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #49 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #50 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #51 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #52 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #53 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #54 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #55 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #56 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #57 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #58 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #59 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #60 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #61 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #62 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #63 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #64 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #65 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #66 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #67 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #68 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #69 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #70 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #71 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #72 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #73 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #74 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #75 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #76 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #77 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #78 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #79 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #80 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #81 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #82 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #83 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #84 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #85 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #86 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #87 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #88 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #89 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #90 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #91 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #92 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #93 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #94 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #95 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #96 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #97 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #98 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #99 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #100 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #101 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #102 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #103 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #104 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #105 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #106 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #107 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #108 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #109 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #110 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #111 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #112 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #113 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #114 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #115 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #116 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #117 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #118 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #119 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #120 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #121 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #122 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #123 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #124 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #125 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #126 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #127 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #128 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #129 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #130 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #131 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #132 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #133 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #134 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #135 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #136 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #137 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #138 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #139 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #140 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #141 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #142 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #143 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #144 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #145 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #146 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #147 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #148 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #149 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #150 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #151 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #152 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #153 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #154 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #155 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #156 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #157 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #158 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #159 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #160 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #161 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #162 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #163 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #164 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #165 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #166 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #167 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #168 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #169 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #170 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #171 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #172 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #173 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #174 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #175 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #176 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #177 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #178 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #179 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #180 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #181 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #182 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #183 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #184 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #185 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #186 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #187 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #188 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #189 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #190 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #191 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #192 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #193 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #194 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #195 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #196 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #197 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #198 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #199 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #200 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #201 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #202 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #203 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #204 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #205 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #206 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #207 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #208 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #209 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #210 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #211 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #212 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #213 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #214 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #215 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #216 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #217 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #218 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #219 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #220 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #221 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #222 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #223 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #224 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #225 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #226 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #227 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #228 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #229 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #230 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #231 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #232 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #233 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #234 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #235 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #236 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #237 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #238 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #239 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #240 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #241 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #242 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #243 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #244 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #245 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #246 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #247 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #248 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c
    #249 0x572863 in ExprTreeBuildTree /home/karas/jimtcl/jim.c

SUMMARY: AddressSanitizer: stack-overflow /home/karas/jimtcl/jim.c:8827 in ExprTreeBuildTree
==11855==ABORTING

dict replace unstable

Hi Steve,

I have found that the --random-hash makes test dict2.test:4.1 fail randomly.
You can see it failing with these commands, which should just give an endless column of "a b c d"
./configure --random-hash && make
while true; do ./jimsh -e "dict replace {a b c d}"; done`

Instead of "a b c d", fairly often "c d a b" is returned.

Regards,
Evan

Allow passing a NULL msg to Jim_WrongNumArgs

Untested!

--- jim.c.orig  Wed Jun  6 16:05:13 2018
+++ jim.c       Wed Jun  6 16:05:27 2018
@@ -11183,7 +11183,7 @@ void Jim_WrongNumArgs(Jim_Interp *interp, int argc, Ji
 
     listObjPtr = Jim_NewListObj(interp, argv, argc);
 
-    if (*msg) {
+    if (msg && *msg) {
         Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, msg, -1));
     }
     Jim_IncrRefCount(listObjPtr);

I/O on windows with utf-8 enabled has issues

As explained here, http://utf8everywhere.org, accessing files on Windows with non-ansi filenames requires use "wide" APIs. This means using _wfopen rather than fopen, CreateFileW instead of CreateFile, etc.

Here is a list of known APIs that need to be addressed:

  • fopen (_wfopen)
  • stat (_wstat64)
  • rename (_wrename)
  • mkdir (_wmkdir)
  • opendir/readdir (_wopendir, _wreaddir)
  • _open (_wopen)
  • access (_waccess)

Tests don't run properly if Jim not built in src dir.

I'm using this patch.

--- Makefile.in.orig    Sun Apr  5 12:22:11 2015
+++ Makefile.in Sun Apr  5 12:24:43 2015
@@ -112,7 +112,7 @@
 @endif

 test check: $(JIMSH)
-   cd @srcdir@/tests; $(DEF_LD_PATH) $(MAKE) jimsh=@builddir@/jimsh
+   cd @srcdir@/tests; $(DEF_LD_PATH) JIMLIB='@top_srcdir@' $(MAKE) jimsh=@builddir@/jimsh

 $(OBJS): Makefile $(wildcard *.h)

0.76 → 0.77 Regression on hppa - timer-6.5 test fails

Bug-Debian: https://bugs.debian.org/873048

The 0.77 upload to Debian has revealed that this version has regressed on the hppa architecture, see https://buildd.debian.org/status/logs.php?pkg=jimtcl&arch=hppa

  timer-6.5 ERR Tcl_AfterCmd procedure, ms argument
  At      : timer.test:192
  Expected: 'before after'
  Got     : 'after after'
  
        timer.test: Total    44   Passed    43  Skipped     0  Failed     1
  ------------------------------------------------------------
  FAILED: 1
  	timer.test:192	timer-6.5
  [...]
  =========================================================================
            Totals: Total  4722   Passed  4502  Skipped   219  Failed     1

As Aaron highlighted:

I'm not sure if this error stemmed from a random glitch or a
consistent problem, but either way tests should consistently
succeed. ;-) Could you please take a look?

I'm happy to help getting that fixed (I can get access to hppa developer machines) if you have patches.

typos

Jim_WrongNumArgs(interp, 1, argv, "libaryFile");

jimtcl/jim.c

Line 3795 in 0f2d8ef

* That is, the fully qualfied name without the leading ::

jimtcl/jim.c

Line 4185 in 0f2d8ef

* every time. The information cached may not be uptodate, in such

jimtcl/jim.c

Line 4279 in 0f2d8ef

* Variable and procedure names are maniplated as null terminated strings, so

jimtcl/jim.c

Line 4309 in 0f2d8ef

/* Check if the object is already an uptodate variable */

jimtcl/jim.c

Line 4710 in 0f2d8ef

* of the variable to set, and the second with the rispective key.

jimtcl/jim.c

Line 5836 in 0f2d8ef

/* Simple switcheroo */

jimtcl/jim.c

Line 6911 in 0f2d8ef

/* Drop the space calcuated for this

jimtcl/jim.c

Line 7111 in 0f2d8ef

* The higer-level exported function is Jim_DictAddElement().

Cannot use pipelines created by open with exec

The documentation for open and exec suggest I should be able to use a pipeline created by open as a file descriptor with exec. I think both of the following execs should produce a list of numbers from 10 to 1:

humax# seq 1 10 > test_input.txt
humax# jimsh
Welcome to Jim version 0.75
. set f [open "test_input.txt" r]
::aio.handle4
. exec sort -rn <@ $f
10
9
8
7
6
5
4
3
2
1
. set f [open "| seq 1 10" r]
<reference.<functio>.00000000000000000000>
. exec sort -rn <@ $f
Not a filehandle: "<reference.<functio>.00000000000000000000>"
[error] . 

`package require` returns corrupted version string

package require sometimes returns a corrupted version string. It seems that the version string gets garbage collected. ef5f515 fixes this issue for me. At least no further corrupted string appeared in my tests.

I've also removed the forced version number for "compiled tcl extensions" in 6f51a99. The package loader seems to provide the default version '1.0' already for extensions not providing a version number.

[package require Tcl 8.6] fails

According to the docs, the Jim version of package require is supposed to support an optional version number, but it fails with

Error: wrong # args: should be "package cmd pkg"

I got as far as seeing that this has something to do with proc package not declaring its optional arity correctly, but my Tcl fu is not strong enough to provide a patch.

My immediate need is to check for compatibility with a particular version of Tcl, but this may affect other packages.

That then begs the question, what version of Tcl should Jim claim to be equivalent to? There are elements from Tcl 8.6 (e.g. lmap), but there are also many things in 8.6 that Jim either doesn't support statically or which may be compiled out in the current build (e.g. file normalize).

C API documentation

Hi,

Really liking jimtcl, and attempting to embed it as the primary shell to my embedded kernel. Is there any documentation on the C api? Or should I roughly take the official TCL c api documentation as a reference?

I want to create some commands that create some objects (which can be garbage collected) that are returned and can be manipulated in a script.

Are there any examples of this? I.e. Other than a string or int object.

James

Incorrect description of [local]

Asciidoc documentation for [local] claims that its arguments are concatenated as per [eval], which I believe is not true: it interprets its arguments as separate command words without any additional interpretation, like [tailcall]. See line 12598 of jim.c as of commit 666f15f.
(This also happens to be the most reasonable thing to do in a world with {*}. Sadly, [uplevel] doesn't work like this, and changing it will probably break lots of code in subtle ways.)

0.76 → 0.77 Regression on hurd-i386 - exec-12.1 test fails

Bug-Debian: https://bugs.debian.org/873049

The 0.77 upload to Debian has revealed that this version has regressed on the hurd-i386 architecture, see https://buildd.debian.org/status/logs.php?pkg=jimtcl&arch=hurd-i386

  exec-12.1 ERR reaping background processes
  At      : exec.test:347
  Expected: '0'
  Got     : 'child'
  
         exec.test: Total    76   Passed    75  Skipped     0  Failed     1
  ------------------------------------------------------------
  FAILED: 1
  	exec.test:347	exec-12.1
  [...]
  =========================================================================
            Totals: Total  4722   Passed  4503  Skipped   218  Failed     1

I'm happy to help getting that fixed (I can get access to hurd-i386 developer machines) if you have patches.

Segmentation Faults 2017-08-03

Hi again. Continued fuzz testing came up with more inputs worth looking at.
See here: https://github.com/rwhitworth/jimtcl-fuzz/tree/master/2017-08-03

I compiled a 'hardened' version of jimsh that includes extra memory protections to catch out of bound reads, double free, and other issues. Some of these inputs may not crash a default build of jimsh, so be aware. I would be glad to help double-check any fixes. These were found with a previous version, and were re-confirmed against commit 59f01cb.

gdb output from a few examples so you know what type of stuff is included:

id:000040,sig:06,src:001944,op:havoc,rep:4

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007f0416b043fa in __GI_abort () at abort.c:89
#2  0x00007f0416b40bd0 in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7f0416c35dd0 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007f0416b46f96 in malloc_printerr (action=3, str=0x7f0416c35f28 "double free or corruption (fasttop)", ptr=<optimized out>, ar_ptr=<optimized out>)
    at malloc.c:5049
#4  0x00007f0416b477de in _int_free (av=0x7f0416e69b00 <main_arena>, p=0x1ecd550, have_lock=0) at malloc.c:3905
#5  0x000000000040bdc7 in Jim_Free (ptr=0x2) at jim.c:653
#6  Jim_FreeObj (interp=<optimized out>, objPtr=0x1ed3fb0) at jim.c:2194
#7  Jim_SetResultFormatted (interp=<optimized out>, format=<optimized out>) at jim.c:15466
#8  0x000000000041163a in SetBooleanFromAny (flags=1, interp=<optimized out>, objPtr=<optimized out>) at jim.c:6127
#9  Jim_GetBoolean (interp=0x1eaf010, objPtr=0x1ed3fb0, booleanPtr=0x7ffe970ed3bc) at jim.c:6103
#10 0x00000000004222a4 in ExprBool (obj=0x1ed3fb0, interp=<optimized out>) at jim.c:8250
#11 JimExprGetTermBoolean (interp=0x1eaf010, node=<optimized out>) at jim.c:9220
#12 0x00000000004207e6 in JimExprOpAnd (interp=0x1eaf010, node=0x1eda430) at jim.c:8263
#13 0x0000000000415da2 in JimExprEvalTermNode (interp=0x1eaf010, node=0x7ffe970ecc50) at jim.c:9160
#14 0x00000000004148c2 in Jim_EvalExpression (interp=0x1eaf010, exprObjPtr=<optimized out>) at jim.c:9320
#15 0x0000000000419100 in JimExpandExprSugar (interp=0x1eaf010, objPtr=0x7ffe970ecc50) at jim.c:4933
#16 JimSubstOneToken (interp=<optimized out>, token=<optimized out>, objPtrPtr=<optimized out>) at jim.c:10187
#17 JimInterpolateTokens (interp=<optimized out>, token=<optimized out>, tokens=<optimized out>, flags=<optimized out>) at jim.c:10238
#18 0x000000000041828b in Jim_EvalObj (interp=<optimized out>, scriptObjPtr=<optimized out>) at jim.c:10481
#19 0x000000000041a4c8 in Jim_EvalFile (interp=0x1eaf010, filename=<optimized out>) at jim.c:10928
#20 0x000000000040743d in main (argc=<optimized out>, argv=0x7ffe970ed7f8) at jimsh.c:140

id:000377,sig:11,src:007620,op:ext_AO,pos:476

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007f1f7d7073fa in __GI_abort () at abort.c:89
#2  0x00007f1f7d743bd0 in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7f1f7d838dd0 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007f1f7d749f96 in malloc_printerr (action=3, str=0x7f1f7d838f08 "double free or corruption (top)", ptr=<optimized out>, ar_ptr=<optimized out>)
    at malloc.c:5049
#4  0x00007f1f7d74a7de in _int_free (av=0x7f1f7da6cb00 <main_arena>, p=0xd0f660, have_lock=0) at malloc.c:3905
#5  0x000000000041e805 in Jim_Free (ptr=0x2) at jim.c:653
#6  FreeListInternalRep (interp=<optimized out>, objPtr=<optimized out>) at jim.c:6168
#7  0x000000000041d51c in Jim_FreeObj (interp=0xce3010, objPtr=0xd0f340) at jim.c:2190
#8  FreeDictSubstInternalRep (interp=0xce3010, objPtr=0xd0bee0) at jim.c:4875
#9  0x000000000041e2af in Jim_FreeObj (objPtr=0xd0bee0, interp=<optimized out>) at jim.c:2190
#10 JimVariablesHTValDestructor (interp=0xce3010, val=0xd0c0e0) at jim.c:3812
#11 0x0000000000408a81 in Jim_FreeHashTable (ht=<optimized out>) at jim.c:921
#12 0x0000000000410afb in JimFreeCallFrame (interp=<optimized out>, cf=<optimized out>, action=<optimized out>) at jim.c:5031
#13 0x000000000040fabe in Jim_FreeInterp (i=<optimized out>) at jim.c:5539
#14 0x000000000040756c in main (argc=<optimized out>, argv=<optimized out>) at jimsh.c:156

id:000452,sig:06,src:007658,op:havoc,rep:8

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007f338e8cf3fa in __GI_abort () at abort.c:89
#2  0x00007f338e90bbd0 in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7f338ea00dd0 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007f338e911f96 in malloc_printerr (action=3, str=0x7f338ea00f08 "double free or corruption (top)", ptr=<optimized out>, ar_ptr=<optimized out>)
    at malloc.c:5049
#4  0x00007f338e9127de in _int_free (av=0x7f338ec34b00 <main_arena>, p=0x23c5ff0, have_lock=0) at malloc.c:3905
#5  0x000000000041d556 in Jim_Free (ptr=0x2) at jim.c:653
#6  Jim_FreeObj (interp=<optimized out>, objPtr=0x23c5cf0) at jim.c:2194
#7  FreeDictSubstInternalRep (interp=0x2396010, objPtr=0x23c4620) at jim.c:4875
#8  0x000000000041e2af in Jim_FreeObj (objPtr=0x23c4620, interp=<optimized out>) at jim.c:2190
#9  JimVariablesHTValDestructor (interp=0x2396010, val=0x23bf160) at jim.c:3812
#10 0x0000000000408a81 in Jim_FreeHashTable (ht=<optimized out>) at jim.c:921
#11 0x0000000000410afb in JimFreeCallFrame (interp=<optimized out>, cf=<optimized out>, action=<optimized out>) at jim.c:5031
#12 0x000000000040fabe in Jim_FreeInterp (i=<optimized out>) at jim.c:5539
#13 0x000000000040756c in main (argc=<optimized out>, argv=<optimized out>) at jimsh.c:156

Choose better doc format

Hi! This audacious request is because asciidoc is needed to build the Jim docs.

On OpenBSD this makes the port pull in asciidoc + a bunch of dependencies and it's slow to generate the docs.
Could you please change the docs to another format?

As I said, this is an audacious request and I don't expect you to change your doc format just because I don't like it so much but this was easier to do at this moment than sending an email. :D

./jim-nvp.h is missing

when I tried to build the project

sudo gmake install

the makefile complained that

./jim-nvp.h

did not exist. It was defined in the Makefile.in and generated Makefile, however, the file is not in the project. And when I removed the file from the Makefile(s) it built nicely.

if 1 {puts "}$"}; if 1 { puts "}$" }

[jianhong@dhcp-12-125 ~]$ jimsh
Welcome to Jim version 0.77
. puts "}$"
}$
. if 1 { puts "}$" } else { puts x }
$
. if 1 { puts "}$" } else { puts x }
}$

Segmentation faults

Hello,
I was using American Fuzzy Lop (afl-fuzz) to fuzz input and found a few inputs that cause crashes. Is fixing these crashes something you're interested in? The input files can be found here: https://github.com/rwhitworth/jimtcl-fuzz/ and they have been trimmed down to the smallest possible set of test cases using afl-cmin.

The files are inputs that can be executed as jimsh id:00:xx to cause seg faults

Let me know if I can provide any more information to help narrow down this issue.

Line continuation in curly braces

Jim does not process line continuations in curly braces, which causes incompatibility with Tcl 8 code.

$ cat demo.tcl 
puts "$tcl_platform(engine) [info patchlevel]"
puts "foo\
      bar"
set s {lorem\
       ipsum}
puts $s
puts [string length [lindex $s 0]]

$ tclsh demo.tcl 
Tcl 8.6.8
foo bar
lorem ipsum
5

$ jimsh demo.tcl 
Jim 0.77
foo bar
lorem\
       ipsum
6

bractrace(3) not detected on NetBSD

The backtrace(3) function is in the libexecinfo library (-lexecinfo).

How to make it detectable? I was trying to specify LIBS=-lexecinfo but it fails.

Resolving magic strings as Boolean

Whilst I personally find it bad style, TCL states that "true", "false", "yes", "no", "on", "off" should be interpreted as their boolean counterparts. jimtcl does not appear to handle this, and is breaking some legacy code of mine.

The following works using libtcl, but not with jimtcl.

set VAR true
if { $VAR } { puts "$VAR is true" }

http://wiki.tcl.tk/16235

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.