Commit graph

98 commits

Author SHA1 Message Date
Leonardo de Moura
7a58da1181 fix(library/tactic/user_attribute): nasty interaction between eval_expr and attribute_manager
eval_expr creates auxiliary definitions in the VM. These auxiliary
definitions are gone after the VM finishes.

We store vm_obj's in the attribute_manager.

Before this commit, Lean was crashing in the following scenario:

1- A new caching_user_attribute is defined, and the user data structure
contains closures.

2- The closures are created using eval_expr.

3- When reusing the cached values, the system crashes when trying
to apply a closure created using eval_expr. The closure points to
an auxiliary definition that has already been deleted.

The new test exposes the problem. This is not a hypothetical scenario,
the new test is based on the Lean - Mathematica integration being
developed by @rlewis1988.

The fix consists in making sure we do not cache anything if
the VM environment has been updated by eval_expr.

I believe this is acceptable behavior. eval_expr is a very low level
tactic, and I don't see a good motivation for invoking it when
constructing the cache.

BTW, the test can be relaxed if the vm_attr does not contain closures.
However, it doesn't seem to pay off.

Another potential fix would be to propagate the definitions created
by eval_expr to the main environment. However, I think this is not
acceptable.
We will be flooding the main environment with useless temporary definitions
created by `eval_expr`.

This commit also stores the environment at caching time, and make
sure the cache is only reused if the current environment is a descendant
of the the one at caching time. This is fixing a different potential
bug.
2017-02-10 15:24:01 -08:00
Gabriel Ebner
94565113a6 chore(checker): remove gmp, mpfr, and dl library dependencies 2017-01-31 09:39:31 +01:00
Gabriel Ebner
952f444710 feat(init/meta/task): allow task creation from VM 2017-01-28 08:27:23 +01:00
Leonardo de Moura
6f502b9afd fix(library/vm): make sure vm_rb_map objects can be stored in ts_vm_obj
See discussion at #1337
2017-01-26 15:58:11 -08:00
Leonardo de Moura
4e625b35ad fix(library/vm/vm): memory leak at operator= 2017-01-26 13:32:44 -08:00
Leonardo de Moura
7a6b9e193c feat(library/vm, frontends/lean/info_manager): add thread safe vm_obj wrapper, and use it to store arbitrary vm thunks in the info_manager 2017-01-21 22:38:33 -08:00
Leonardo de Moura
3967cd28fa fix(library/vm/vm): curr_fn() may not be available 2017-01-12 11:47:45 -08:00
Leonardo de Moura
ff455d3ec9 chore(library/vm/vm): warning 2017-01-06 21:22:27 -08:00
Leonardo de Moura
de8ba72a86 feat(library/vm/vm): suppress snapshots when printing profiling information 2017-01-06 19:22:07 -08:00
Leonardo de Moura
94e6fbcbbf perf(library/vm/vm): make sure builtin cases_on recursors are assigned ids first
This will minimize the size of the m_builtin_cases_vector.
It also indirectly prevents the crash decribed at 144d9096e2.
However, the fix used there is more robust.
2016-12-22 18:46:51 -08:00
Leonardo de Moura
144d9096e2 fix(library/vm/vm): serialization/deserialization of builtin cases_on instruction
We generate internal ids for builtin cases_on recursors.
These ids were being saved in the .olean files.
This was fine before commit 41e8a1712e because we had a separate
mapping for builtin cases_on recursors. Now, all ids are stored in the
same mapping. Thus, minor changes in the set of VM builtin operations
make lean crash when importing .olean files because they will change the
internal id for the builtin cases_on.
The problem can be reproduced in the following way:

0- Go to build/release

1- make clean-olean

2- make
Everything is fine after step 2

3- Comment the following line at tactic_state.cpp

    DECLARE_VM_BUILTIN(name({"tactic", "open_namespaces"}),      tactic_open_namespaces);

4- make

5- Lean will crash when executing the following command

   ../../bin/lean ../../library/init/meta/tactic.lean

I believe this bug is reponsible by the crash that @jroesch reported on Slack.

This commit fixes the problem by storing the name of the builtin
cases_on recursor in the .olean file.
2016-12-22 18:35:30 -08:00
Leonardo de Moura
e5c4231248 fix(library/vm/vm): bug at vm_index_manager?
@gebner, I have been experiencing crashes that are hard to reproduce.
I think one of the problems was that get_vm_name was returning a `name const &`.
I think this may produce a memory access violation in the following
scenario:

1- Thread 1 invokes get_vm_name, and gets a reference R. This is a
   reference to a memory cell in the vector m_idx2name.
2- Thread 2 invokes get_vm_index, and it triggers a vector resize
   operation. After the resize, reference R is invalid.
3- Thread 1 crashes trying to access R.
2016-12-22 18:19:33 -08:00
Leonardo de Moura
5f72e37501 chore(library/vm): fix warning 2016-12-20 10:19:20 -08:00
Gabriel Ebner
a26e2c9108 feat(library/module): intermediary data structure for environment modifications 2016-12-20 10:15:19 -08:00
Gabriel Ebner
41e8a1712e refactor(library/vm): use global indices for declarations and cases 2016-12-20 10:13:58 -08:00
Leonardo de Moura
e248577e1c feat(library/vm): allow vm bytecode to invoke native closures 2016-12-14 19:16:55 -08:00
Leonardo de Moura
b0ce461fcd feat(library/vm): native closures that do not depend on vm_state
Remark: native_closures are used in the C++ code generator.
2016-12-14 18:51:24 -08:00
Leonardo de Moura
fe3396e1ae perf(library/vm/vm): cache the result of 0-ary vm_decls 2016-12-12 09:12:06 -08:00
Leonardo de Moura
e59515df5f chore(*): fix style 2016-12-05 16:39:58 -08:00
Jared Roesch
e65d90ac79 feat(*): C++ code generator
in progress move of Lean.native to init
2016-12-05 16:11:41 -08:00
Gabriel Ebner
7db2b8d014 fix(library/vm/vm): do not segfault in single-threaded builds 2016-12-02 16:51:10 -08:00
Gabriel Ebner
a8df381d20 feat(*): parallel compilation 2016-11-29 11:12:40 -08:00
Leonardo de Moura
31e159b80c fix(library/vm/vm): bug at add_native 2016-11-21 16:58:22 -08:00
Leonardo de Moura
91c8ff746f feat(cli_debugger): add commands for traversing stack frames 2016-11-16 12:37:18 -08:00
Leonardo de Moura
3628870121 feat(library/tactic/vm_monitor): extend VM introspection API 2016-11-15 15:05:46 -08:00
Leonardo de Moura
fffe69fdf9 feat(library/vm,library/tactic/vm_monitor): use optionT to define vm monad 2016-11-14 16:13:56 -08:00
Leonardo de Moura
7232e3a076 feat(library/vm/vm): invoke debugger (aka vm_monitor) 2016-11-14 14:45:49 -08:00
Leonardo de Moura
a7344671e1 feat(library/vm/vm): add stack_info 2016-11-13 12:20:02 -08:00
Leonardo de Moura
381b2edaf7 feat(library/vm/vm): store .olean file name at vm_decl's 2016-11-11 16:19:19 -08:00
Leonardo de Moura
e673fa65ba feat(library/vm/vm): Store position information at vm_decl's 2016-11-11 15:39:32 -08:00
Leonardo de Moura
b79b76db83 feat(library/compiler/vm_compiler): improve local_info collection 2016-11-09 12:18:44 -08:00
Leonardo de Moura
6b3da2daf4 feat(library/compiler/vm_compiler): save local_info for let-expressions 2016-11-08 15:50:38 -08:00
Leonardo de Moura
d66584f390 feat(library/vm,library/compiler): save argument names 2016-11-08 15:10:04 -08:00
Gabriel Ebner
e88b97d46d fix(library/vm/vm): initialize m_total_time field 2016-11-07 15:03:25 -08:00
Leonardo de Moura
1dcc21525a chore(library/vm/vm): style 2016-11-04 09:55:20 -07:00
Leonardo de Moura
5075891f66 chore(library/vm/vm): fix gcc 4.8 warning 2016-11-04 09:46:16 -07:00
Gabriel Ebner
ef1fc9871b feat(library/vm/vm): profiler: show cumulative runtimes 2016-11-04 09:39:12 -07:00
Leonardo de Moura
9465f25f09 feat(library/vm): profiler for VM bytecode 2016-11-03 21:15:29 -07:00
Leonardo de Moura
6b582ca6c3 fix(library/vm/vm): bug at get_constant 2016-10-04 01:58:39 -07:00
Leonardo de Moura
545b89d556 fix(library/vm): memory violation 2016-10-04 00:09:52 -07:00
Leonardo de Moura
4ee9554c96 fix(library/vm/vm): reference may be invalidated when the vector is resized 2016-10-03 21:31:17 -07:00
Leonardo de Moura
a0a7e22bb7 fix(library/vm/vm): uninitialized variable 2016-10-03 21:25:30 -07:00
Leonardo de Moura
4a2946f5dd feat(library/tactic/eval): eval_expr for arbitrary expressions 2016-10-03 19:01:22 -07:00
Leonardo de Moura
12eb886f49 refactor(library/vm/vm): remove parray 2016-10-03 17:26:03 -07:00
Leonardo de Moura
7465529445 feat(library/tactic): 'eval_expr' tactic skeleton 2016-10-03 16:26:28 -07:00
Leonardo de Moura
199decea51 fix(library/tactic/tactic_state): remove problematic get_tactic_vm_state 2016-08-23 07:38:44 -07:00
Leonardo de Moura
7bb6ccc089 refactor(library/init/meta): qexpr ==> pexpr 2016-08-05 17:04:36 -07:00
Leonardo de Moura
5ffbc2f94e fix(library/vm/vm): memory leak 2016-08-01 23:06:53 -07:00
Leonardo de Moura
a30603405c feat(library/vm/vm): add scope_vm_state 2016-07-15 15:10:04 -04:00
Leonardo de Moura
d604cb8b4e feat(library/vm/vm): add friendly invoke method 2016-06-24 15:49:40 -07:00