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

Bug calling _iter metametoth after creating Array or Object #361

Open
jespa007 opened this issue Jan 10, 2024 · 0 comments
Open

Bug calling _iter metametoth after creating Array or Object #361

jespa007 opened this issue Jan 10, 2024 · 0 comments
Assignees

Comments

@jespa007
Copy link
Owner

This causes a segmentation fault

class A{
	constructor(){
		this.iter=[]._iter();
	}
}

(new A())

The output code is the following,

ScriptFunction: '@MainFunction'                                             
 Stack code: 2                                                    
 Stack local vars: 0                                         
 Total stack required: 2                                     
 Scopes: 1                                                   

 NUM |RS|AS|               BYTE CODE                        
-----+--+--+--------------------------------------------------
[0000| 1|01]    NEW_OBJECT_BY_TYPE      A
[0001| 1|02]    LOAD_CONSTRUCTOR_FUNCT  constructor
[0002|-1|00]    CALL_CONSTRUCTOR        arg:0 ret:0 [RST]

______________________________________________________________

 ScriptFunction: 'A::constructor'                                             
 Stack code: 3                                                    
 Stack local vars: 0                                         
 Total stack required: 3                                     
 Scopes: 0                                                   

 NUM |RS|AS|               BYTE CODE                        
-----+--+--+--------------------------------------------------
[0000| 1|01]    NEW_ARRAY
[0001| 1|02]    LOAD_OBJ@ITEM           _iter [CALL]
[0002| 0|02]    MEMBER_CALL             arg:0 ret:1 
[0003| 1|03]    PUSH_STK_THIS@VAR       this.iter [SLOT]
[0004|-1|00]    STORE                   n:1 [RST]

Segmentation fault (core dumped)

As a solution could be do not call _iter just after creation (i.e NEW_ARRAY or NEW_OBJECT instruction)

@jespa007 jespa007 self-assigned this Jan 10, 2024
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

1 participant