Closed mzavadil closed 5 years ago
Are you able to provide me with a backtrace when the crash happens?
I did a little debugging in VS2017:
Cadabra crashes in DataCell.cc
during eval
python script by PyRun_String
:
# -*- coding: utf-8 -*-
R=Ex(r'R_{a b c d}')
RiemannTensor(R, Ex(r''))
A=Ex(r'A^{a b c}')
AntiSymmetric(A, Ex(r''))
ex=A*R
young_project_tensor(ex, modulo_monoterm = True)
on null pointer
dereference in cadabra2.pyd
module if script contains line:
young_project_tensor(ex, modulo_monoterm = True)
Note: this code part is not at git repository, I added it for debugging only.
PyObject* ex = PyErr_Occurred();
if (ex) {
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
//pybind11_fail("Python script error: " + value.c_str());
}
For more information, there is necessary debug module cadabra2.pyd
at method young_project_tensor
, but I do not know exactly how. If you tell me the concrete steps, I can try to debug myself.
I tried to run it in WinDBG:
And the null pointer dereference problem seems to be in indexsort.cc
line 41 where pointer tb
is null.
In DEBUG mode is all OK because method indexsort::can_apply()
checks a null of tb
pointer resp. sets it by assert
macro at young_project_tensor.cc
:
if(modulo_monoterm) { // still necessary for column exchange
indexsort isort(kernel, rep);
assert(isort.can_apply(newtensor)); // to set tb
isort.apply(newtensor);
}
But assert
macro is deactivated in RELEASE mode when NDEBUG is defined, see: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=vs-2017
Solution is in either project do not use assert
macro for business logic (only checks which can be in release mode safely neglected) or do not build with NDEBUG directive.
Thanks for tracking this down; linux compilers typically leave asserts in release code so that's why I never noticed it. I'll do a grep through the source, there may be other cases of this problem.
I have moved (hopefully all) content of assert macros which has side effects out of the assert, so it will generate the correct code even with NDEBUG; 8e837207bb9e417e1deb4a1754d649a0762e009a . Can you test this for me please?
I tried to build the last commit, but with compilation error: build_error.txt
Probably an invalid syntax of generic iterator do_subtree
in header file Functional.hh
occurred from the previous commit.
After cherry-picked your fix https://github.com/kpeeters/cadabra2/commit/8e837207bb9e417e1deb4a1754d649a0762e009a on commit https://github.com/kpeeters/cadabra2/commit/a4f9fa61d82a6902fa52230a92a2d3a5c9378176 is build successful except tests builds:
"C:\Users\bigfo\Workspace\dev\cadabra2\build\install.vcxproj" (default target) (1) ->
"C:\Users\bigfo\Workspace\dev\cadabra2\build\ALL_BUILD.vcxproj" (default target) (3) ->
"C:\Users\bigfo\Workspace\dev\cadabra2\build\tests\beginners_test.vcxproj" (default target) (4) ->
(CustomBuild target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code 3. [C:\Users\bigfo\Workspace\dev\cadabra2\build\tests\beginners_test.vcxproj]
The problem is probably in unix-like path to echo
utility in tests/CMakeLists.txt
.
add_custom_target("${NBTEST}_test" ALL /bin/echo -n DEPENDS ${CDBOUT}/${NBTEST}.cdb)
I changed it to:
(internal cmd command echo
has not support for the parameter -n
)
add_custom_target("${NBTEST}_test" ALL echo DEPENDS ${CDBOUT}/${NBTEST}.cdb)
and build is complete successful.
Only ctest
command don't passed for this "echo" manipulations :(
Start 1: quickstart
1/43 Test #1: quickstart .......................***Failed 0.24 sec
Start 2: beginners
2/43 Test #2: beginners ........................***Failed 0.12 sec
Start 3: tensor_monomials
3/43 Test #3: tensor_monomials .................***Failed 0.12 sec
Start 4: for_previous_users
4/43 Test #4: for_previous_users ...............***Failed 0.13 sec
Start 5: converge```
But reported bug of this issue is fixed - windows version of Cadabra2 don't crashes anymore.
Unfortunately your fix of young_project_tensor
don't work for statements contains Derivative
:
# -*- coding: utf-8 -*-
from cadabra2 import *
print("start...")
print(Indices(Ex(r"{a,b}"), Ex(r"")))
print(AntiSymmetric(Ex(r"F^{a b}"), Ex(r"")))
print(Derivative(Ex(r"\nabla{#}"), Ex(r"")))
ex = Ex(r"\nabla_{b}{ F^{a b} }")
print(ex)
_ = young_project_tensor(ex)
The problem is again in null pointer dereference of tb
, this time in the module core\properties\derivative.cc
:
Note: It was built from last commint https://github.com/kpeeters/cadabra2/commit/8e837207bb9e417e1deb4a1754d649a0762e009a with excluded build-invalid commit https://github.com/kpeeters/cadabra2/commit/c4a590bf7a17d8272c9455fdb75d1e2c6cc6bdec.
That's a different bug, thanks for reporting it. Now fixed with commit 466b4e68b7e492b2d77fb36f5d20b9df157585d7 .
Your build error should now be fixed on the master branch, please let me know whether it works on your end.
I confirm, build error related to syntax problem in Functional.hh
has been fixed, but there is still the problem with the echo
utility in tests/CMakeLists.txt
. Without its repair, whole build of Cadabra2 fails on
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code 3. [C:\Users\bigfo\Workspace\dev\cadabra2\build\tests\beginners_test.vcxproj]
Then there is one more specific problem with cmake
. I will create new issue for it.
Have replaced /bin/echo with echo.
Windows version of Cadabra2 crashed for any expression on
young_project_product
oryoung_project_tensor
withmodulo_monoterm=True
(if this parameter set toFalse
computation ok).I tried to build three versions from source code: current master from 14.2.2019, version with tag 2.2.5 and 2.2.4. The same problem for each of them.
Windows version:
Microsoft Windows 10 Pro: 10.0.17763 Build 17763
conda info
conda list
MikTeX version:
2.9.6972