Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toncli run_tests -> "Stack underflow. Last op-code consume more elements ..." #103

Closed
kuk opened this issue Dec 9, 2022 · 4 comments
Closed

Comments

@kuk
Copy link

kuk commented Dec 9, 2022

Bug Type

Functional

Reproduction steps

project.yaml

contract:
  func:
    - code.func
  tests:
    - test.func

code.func

() recv_internal (slice in_msg_body) {
}

int sum(int a, int b) {
    return a + b;
}

test.func

_ __test_sum() {
    var (_, stack) = invoke_method(sum, [1, 2]);
    [int data] = stack;
    throw_if(200, data != 3);
}
% toncli run_tests 
INFO: 🌈 Start tests
INFO: 🥌 Build successfully, check out ./build
[ 3][t 0][2022-12-09 11:49:01.925083][vm.cpp:558]	steps: 28 gas: used=2443, max=1000000000, limit=1000000000, credit=0
INFO: Test [__test_sum] status: [FAIL], code: [2], error description [Stack underflow. Last op-code consume more elements than there are on stacks. (most probably means a error in asm declarations)] Total gas used (including testing code): [2443]

Final status: [SUCCESS] - 0 cases
Final status: [FAILED] - 1 cases

Actual result

INFO: Test [__test_sum] status: [FAIL], code: [2], error description [Stack underflow. Last op-code consume more elements than there are on stacks. (most probably means a error in asm declarations)] Total gas used (including testing code): [2443]

Expected result

INFO: Test [__test_sum] status: [SUCCESS]

Suggested Severity

Low

Device

mac m1

toncli --version
INFO: v0.0.43

% ./func -V
FunC semantic version: v0.2.0
Build information: [ Commit: 9640a2794a1cc88a9534991c0709f64f95c1c4e0, Date: 2022-08-11 13:06:52 +0300]

./fift -V
Fift build information: [ Commit: 9640a2794a1cc88a9534991c0709f64f95c1c4e0, Date: 2022-08-11 13:06:52 +0300]

Additional Context

Attach build/contract_tests.fif
contract_tests.fif.txt

@liketurbo
Copy link

Any luck? 😕

@tvorogme
Copy link
Contributor

tvorogme commented Dec 17, 2022

Cant reproduce this issue, please use -v 4 flag in run_tests and share TVM OP codes

Also try to install version from git:

git clone https://github.com/disintar/toncli.git
cd toncli
pip install -e .

Screen Shot 2022-12-17 at 7 34 17 AM

@kuk
Copy link
Author

kuk commented Dec 17, 2022

Using toncli from git

toncli run_tests -v 4

INFO: 🌈 Start tests
INFO: 🥌 Build �[32msuccessfully�[0m, check out �[32m./build�[0m

INFO: 🤳 Tests: �[32m[ [ "__test_sum" 19 ] ]�[0m

 [ 19 ] 
execute SETCP 0
 [ 19 ] 
execute DICTPUSHCONST 19 (xC_,1)
 [ 19 C{40DB3E5D2D55941041BA82DEE05A1D93D33C8B09BD6066C6A22A61AB5E143838} 19 ] 
execute DICTIGETJMPZ
 [ ] 
execute PUSHCONT xF012
 [ ??? ] 
execute PUSHINT 1
 [ ??? 1 ] 
execute PUSHINT 2
 [ ??? 1 2 ] 
execute TUPLE 2
 [ ??? [1 2] ] 
execute PUSHINT 78457
 [ ??? [1 2] 78457 ] 
execute PUSH c3
 [ ??? [1 2] 78457 ??? ] 
execute EXECUTE
 [ ??? [1 2] 78457 ] 
execute SETCP 0
 [ ??? [1 2] 78457 ] 
execute DICTPUSHCONST 19 (xC_,1)
 [ ??? [1 2] 78457 C{40DB3E5D2D55941041BA82DEE05A1D93D33C8B09BD6066C6A22A61AB5E143838} 19 ] 
execute DICTIGETJMPZ
 [ ??? [1 2] ] 
execute PUSH c7
 [ ??? [1 2] [[124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0]] ] 
execute DUP
 [ ??? [1 2] [[124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0]] [[124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0]] ] 
execute INDEX 0
 [ ??? [1 2] [[124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0]] [124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0] ] 
execute GETPARAM 10
 [ ??? [1 2] [[124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0]] [124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0] (()) ] 
execute PUSH c5
 [ ??? [1 2] [[124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0]] [124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0] (()) C{96A296D224F285C67BEE93C30F8A309157F0DAA35DC5B87E410B78630A09CFC7} ] 
execute SETINDEX 1
 [ ??? [1 2] [[124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0]] [124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0] [() C{96A296D224F285C67BEE93C30F8A309157F0DAA35DC5B87E410B78630A09CFC7}] ] 
execute SETINDEX 10
 [ ??? [1 2] [[124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () (()) 0]] [124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () [() C{96A296D224F285C67BEE93C30F8A309157F0DAA35DC5B87E410B78630A09CFC7}] 0] ] 
execute SETINDEX 0
 [ ??? [1 2] [[124711402 0 0 1671261328 1 1671261328 239 (1000000000) CS{Cell{0043800efd7e23ec462b062be53fb98a4c2fd6ad81a0acf00f5cb269bd17e106b1f73010} bits: 0..267; refs: 0..0} () [() C{96A296D224F285C67BEE93C30F8A309157F0DAA35DC5B87E410B78630A09CFC7}] 0]] ] 
execute POP c7
 [ ??? [1 2] ] 
execute NEWC
 [ ??? [1 2] BC{0000} ] 
execute ENDC
 [ ??? [1 2] C{96A296D224F285C67BEE93C30F8A309157F0DAA35DC5B87E410B78630A09CFC7} ] 
execute POP c5
 [ ??? [1 2] ] 
execute DEBUG 239
 [ ??? [1 2] ] 
execute XCHG s1,s3
handling exception code 2: stack underflow
default exception handler, terminating vm with exit code 2
�[1;36m[ 3][t 0][2022-12-17 07:15:28.358384][vm.cpp:558]	steps: 28 gas: used=2443, max=1000000000, limit=1000000000, credit=0�[0m
INFO: Test [�[32m__test_sum�[0m] status: [�[31mFAIL�[0m], code: [�[36m2�[0m], error description [�[36mStack underflow. Last op-code consume more elements than there are on stacks. (most probably means a error in asm declarations)�[0m] Total gas used (including testing code): [�[32m2443�[0m]

Final status: [�[32mSUCCESS�[0m] - �[1m0 cases�[0m
Final status: [�[31mFAILED�[0m] - �[1m1 cases�[0m


@tvorogme
Copy link
Contributor

tvorogme commented Dec 17, 2022

Ok, you're using default fift&func without patched TVM ops that needed for tests. Please, follow installation guide: https://docs.dton.io/toncli/how-to-install or https://github.com/disintar/toncli/blob/master/INSTALLATION.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants