Inappropriate loops behaviour <for(), foreach(), break, continue>, segmentation fault while producing stacktrace #62

Open
opened 2019-12-21 11:13:56 +01:00 by belliash · 3 comments
Owner

AerScript Information

  • Aer Version (or commit ref): ab36234ff3
  • Operating System: Linux
  • System Architecture (eg. arm, x86_64, ...): x86_64

Your problem description

I have written another test - sudoku solver. It causes AerScript interpreter to fail. Sometimes it simply results in no solution, sometimes throws segmentation fault. When investigating issue, I realized this is connected with LOOP frames. After modifying code, to not declare variables repeatedly inside loops and removing OP_LOOP_START and OP_LOOP_START calls from PH7_CompileFor(), PH7_CompileBreak() and PH7_CompileContinue(), attached script has begun to work properly. Additionally, during investigation I have found another problem with for() loop statement:

for(int $a = 0; $a < 5; $a++) {
}
var_dump($a); // shows 4, while it should result in non-existent variable error.

Expected results

3 0 6 5 0 8 4 0 0
5 2 0 0 0 0 0 0 0
0 8 7 0 0 0 0 3 1
0 0 3 0 1 0 0 8 0
9 0 0 8 6 3 0 0 5
0 5 0 0 9 0 6 0 0
1 3 0 0 0 0 2 5 0
0 0 0 0 0 0 0 7 4
0 0 5 2 0 6 3 0 0
=================
3 1 6 5 7 8 4 9 2
5 2 9 1 3 4 7 6 8
4 8 7 6 2 9 5 3 1
2 6 3 4 1 5 9 8 7
9 7 4 8 6 3 1 2 5
8 5 1 7 9 2 6 4 3
1 3 8 9 4 7 2 5 6
6 9 2 3 5 1 8 7 4
7 4 5 2 8 6 3 1 9

Current results

3 0 6 5 0 8 4 0 0 
5 2 0 0 0 0 0 0 0
0 8 7 0 0 0 0 3 1 
0 0 3 0 1 0 0 8 0 
9 0 0 8 6 3 0 0 5
0 5 0 0 9 0 6 0 0 
1 3 0 0 0 0 2 5 0 
0 0 0 0 0 0 0 7 4
0 0 5 2 0 6 3 0 0 
=================
No solution found
AddressSanitizer:DEADLYSIGNAL
=================================================================
==13697==ERROR: AddressSanitizer: SEGV on unknown address 0x60e800050cb4 (pc 0x7f515465b959 bp 0x62d00000a424 sp 0x7fff6d5431d8 T0)
==13697==The signal is caused by a READ memory access.
#0 0x7f515465b958 in PH7_VmExtractActiveClass engine/vm.c:5383
#1 0x7f51546560dc in VmExtractDebugTrace engine/debug.c:47
#2 0x7f515465b292 in PH7_VmThrowError engine/vm.c:1785
#3 0x7f515465dc97 in VmByteCodeExec engine/vm.c:2375
#4 0x7f5154661495 in VmByteCodeExec engine/vm.c:4805
#5 0x7f51546627dd in PH7_VmCallClassMethod engine/vm.c:6193
#6 0x7f515466386a in PH7_VmByteCodeExec engine/vm.c:5082
#7 0x7f5154652f75 in ph7_vm_exec engine/api.c:616
#8 0x55a1e67910c7 in main (/home/Belliash/Documents/Repositories/AerScript/binary/aer+0x10c7)
#9 0x7f515446be9a in __libc_start_main (/lib64/libc.so.6+0x26e9a)
#10 0x55a1e6790be9 in _start (/home/Belliash/Documents/Repositories/AerScript/binary/aer+0xbe9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV engine/vm.c:5383 in PH7_VmExtractActiveClass
==13697==ABORTING
<!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please take a moment to check that your issue doesn't already exist. 3. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> # AerScript Information - Aer Version (or commit ref): ab36234ff3 - Operating System: Linux - System Architecture (eg. arm, x86_64, ...): x86_64 # Your problem description I have written another test - sudoku solver. It causes AerScript interpreter to fail. Sometimes it simply results in no solution, sometimes throws segmentation fault. When investigating issue, I realized this is connected with LOOP frames. After modifying code, to not declare variables repeatedly inside loops and removing OP_LOOP_START and OP_LOOP_START calls from PH7_CompileFor(), PH7_CompileBreak() and PH7_CompileContinue(), attached script has begun to work properly. Additionally, during investigation I have found another problem with for() loop statement: for(int $a = 0; $a < 5; $a++) { } var_dump($a); // shows 4, while it should result in non-existent variable error. # Expected results 3 0 6 5 0 8 4 0 0 5 2 0 0 0 0 0 0 0 0 8 7 0 0 0 0 3 1 0 0 3 0 1 0 0 8 0 9 0 0 8 6 3 0 0 5 0 5 0 0 9 0 6 0 0 1 3 0 0 0 0 2 5 0 0 0 0 0 0 0 0 7 4 0 0 5 2 0 6 3 0 0 ================= 3 1 6 5 7 8 4 9 2 5 2 9 1 3 4 7 6 8 4 8 7 6 2 9 5 3 1 2 6 3 4 1 5 9 8 7 9 7 4 8 6 3 1 2 5 8 5 1 7 9 2 6 4 3 1 3 8 9 4 7 2 5 6 6 9 2 3 5 1 8 7 4 7 4 5 2 8 6 3 1 9 # Current results 3 0 6 5 0 8 4 0 0 5 2 0 0 0 0 0 0 0 0 8 7 0 0 0 0 3 1 0 0 3 0 1 0 0 8 0 9 0 0 8 6 3 0 0 5 0 5 0 0 9 0 6 0 0 1 3 0 0 0 0 2 5 0 0 0 0 0 0 0 0 7 4 0 0 5 2 0 6 3 0 0 ================= No solution found AddressSanitizer:DEADLYSIGNAL ================================================================= ==13697==ERROR: AddressSanitizer: SEGV on unknown address 0x60e800050cb4 (pc 0x7f515465b959 bp 0x62d00000a424 sp 0x7fff6d5431d8 T0) ==13697==The signal is caused by a READ memory access. #0 0x7f515465b958 in PH7_VmExtractActiveClass engine/vm.c:5383 #1 0x7f51546560dc in VmExtractDebugTrace engine/debug.c:47 #2 0x7f515465b292 in PH7_VmThrowError engine/vm.c:1785 #3 0x7f515465dc97 in VmByteCodeExec engine/vm.c:2375 #4 0x7f5154661495 in VmByteCodeExec engine/vm.c:4805 #5 0x7f51546627dd in PH7_VmCallClassMethod engine/vm.c:6193 #6 0x7f515466386a in PH7_VmByteCodeExec engine/vm.c:5082 #7 0x7f5154652f75 in ph7_vm_exec engine/api.c:616 #8 0x55a1e67910c7 in main (/home/Belliash/Documents/Repositories/AerScript/binary/aer+0x10c7) #9 0x7f515446be9a in __libc_start_main (/lib64/libc.so.6+0x26e9a) #10 0x55a1e6790be9 in _start (/home/Belliash/Documents/Repositories/AerScript/binary/aer+0xbe9) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV engine/vm.c:5383 in PH7_VmExtractActiveClass ==13697==ABORTING
Author
Owner

Attached affected script.

Attached affected script.
belliash added the
bug
label 2019-12-21 11:24:11 +01:00
Author
Owner

Revisions c730082fa0 and 709b5971c6 fixes the segmentation fault problem. There is still a need to investigate and resolve problem of variables scopes.

Revisions c730082fa0 and 709b5971c6 fixes the segmentation fault problem. There is still a need to investigate and resolve problem of variables scopes.
Author
Owner

Sudoku solver test added in 3eb82e632b.

Sudoku solver test added in 3eb82e632b.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: aerscript/Aer#62
No description provided.