Crash with array index to empty array

2020-04-06 Thread Elias Mårtenson
Not much to say about this one. A parser crash. Easiest way to reproduce:

*  [⍬]*
non-ASCII char in C-String '⍬'

==
Assertion failed: 0 && "Bad C-string"
in Function:  UCS_string
in file:  UCS_string.cc:93

Call stack:


-- Stack trace at UCS_string.cc:93

0x7FA4229AF1A3 __libc_start_main
0x46E075  main
0x5C7DD5   Workspace::immediate_execution(bool)
0x4BACB9Command::process_line()
0x4BB644 Command::do_APL_expression(UCS_string&)
0x4BAD31  Command::finish_context()
0x4C3967   Executable::execute_body() const
0x56E4D1StateIndicator::run()
0x4F4144 Prefix::reduce_statements()
0x4F005E  Prefix::syntax_error(char const*)
0x4C3888   throw_apl_error(ErrorCode, char const*)
0x4C378BError::update_error_info(StateIndicator*)
0x4C3F35 Executable::set_error_info(Error&, Function_PC2) const
0x5A148E  Token::error_info(UCS_string&) const
0x5A1040   Token::canonical(PrintStyle) const
0x50ED5EPrintBuffer::PrintBuffer(Value const&, PrintContext
const&, std::ostream*)
0x50CC67 PrintBuffer::pb_empty(Value const&, PrintContext,
PrintStyle)
0x5A97DF  UCS_string::UCS_string(char const*)
0x482845   do_Assert(char const*, char const*, char const*,
int)


SI stack:

Depth:  3
Exec:   0x1bcef00
Safe exec:  0
Pmode:  ◊  [⍬]
PC: 4 (5) RETURN_STATS
Stat:   [⍬]
err_code:   0x0

Depth:  2
Exec:   0x1bcd510
Safe exec:  0
Pmode:  ◊  []
PC: 3 (4) RETURN_STATS
Stat:   []
err_code:   0x20002
thrown at:  Prefix.cc:459
e_msg_1:'SYNTAX ERROR'
e_msg_2:'  []'
e_msg_3:'  ^'

Depth:  1
Exec:   0x1bca690
Safe exec:  0
Pmode:  ◊  [0]
PC: 4 (5) RETURN_STATS
Stat:   [0]
err_code:   0x20002
thrown at:  Prefix.cc:459
e_msg_1:'SYNTAX ERROR'
e_msg_2:'  [0]'
e_msg_3:'  ^'

Depth:  0
Exec:   0x1bccfa0
Safe exec:  0
Pmode:  ◊  (3 4 ⍴ 10+⍳12)[1;4]
PC: 13 (15) ENDL
Stat:   (3 4 ⍴ 10+⍳12)[1;4]
err_code:   0x50005
thrown at:  Value.cc:1134
e_msg_1:'INDEX ERROR'
e_msg_2:'  (3 4⍴10+⍳12)[1;4]'
e_msg_3:'  ^   ^'


==


Re: Crash with array index to empty array

2020-04-06 Thread Dr . Jürgen Sauermann

  
  
Hi Elias,
  
  thanks. I believe this  was fixed in SVN 1240.

Best Regards,
Jürgen Sauermann


On 4/6/20 11:11 AM, Elias Mårtenson
  wrote:


  
  
Not much to say about this one. A parser crash. Easiest way
  to reproduce:


      [⍬]
non-ASCII char in C-String '⍬'

==
Assertion failed: 0 && "Bad C-string"
in Function:      UCS_string
in file:          UCS_string.cc:93

Call stack:


-- Stack trace at UCS_string.cc:93

0x7FA4229AF1A3 __libc_start_main
0x46E075  main
0x5C7DD5   Workspace::immediate_execution(bool)
0x4BACB9    Command::process_line()
0x4BB644     Command::do_APL_expression(UCS_string&)
0x4BAD31      Command::finish_context()
0x4C3967       Executable::execute_body() const
0x56E4D1        StateIndicator::run()
0x4F4144         Prefix::reduce_statements()
0x4F005E          Prefix::syntax_error(char const*)
0x4C3888           throw_apl_error(ErrorCode, char const*)
0x4C378B          
 Error::update_error_info(StateIndicator*)
0x4C3F35             Executable::set_error_info(Error&,
Function_PC2) const
0x5A148E              Token::error_info(UCS_string&)
const
0x5A1040               Token::canonical(PrintStyle) const
0x50ED5E                PrintBuffer::PrintBuffer(Value
const&, PrintContext const&, std::ostream*)
0x50CC67                 PrintBuffer::pb_empty(Value
const&, PrintContext, PrintStyle)
0x5A97DF                  UCS_string::UCS_string(char
const*)
0x482845                   do_Assert(char const*, char
const*, char const*, int)


SI stack:

Depth:      3
Exec:       0x1bcef00
Safe exec:  0
Pmode:      ◊  [⍬]
PC:         4 (5) RETURN_STATS
Stat:       [⍬]
err_code:   0x0

Depth:      2
Exec:       0x1bcd510
Safe exec:  0
Pmode:      ◊  []
PC:         3 (4) RETURN_STATS
Stat:       []
err_code:   0x20002
thrown at:  Prefix.cc:459
e_msg_1:    'SYNTAX ERROR'
e_msg_2:    '      []'
e_msg_3:    '      ^'

Depth:      1
Exec:       0x1bca690
Safe exec:  0
Pmode:      ◊  [0]
PC:         4 (5) RETURN_STATS
Stat:       [0]
err_code:   0x20002
thrown at:  Prefix.cc:459
e_msg_1:    'SYNTAX ERROR'
e_msg_2:    '      [0]'
e_msg_3:    '      ^'

Depth:      0
Exec:       0x1bccfa0
Safe exec:  0
Pmode:      ◊  (3 4 ⍴ 10+⍳12)[1;4]
PC:         13 (15) ENDL
Stat:       (3 4 ⍴ 10+⍳12)[1;4]
err_code:   0x50005
thrown at:  Value.cc:1134
e_msg_1:    'INDEX ERROR'
e_msg_2:    '      (3 4⍴10+⍳12)[1;4]'
e_msg_3:    '      ^           ^'


==
  

  


  




Re: seg-fault with deeply nested assignment

2020-04-06 Thread Blake McBride
Without assigning it to a variable, I don't see what sense the
statement even makes.

 (⊃⊃x)

produces an intermediate value.  I can't think of what sense making an
assignment to an intermediate value even does.

I think APL should just throw a syntax error as in:

  (+/10 10⍴⍳100)[2]←4
SYNTAX ERROR
  (+/10 10⍴⍳100)[2]←4
  ^^

(Surely a syntax error is more appropriate than a segfault!)

What does IBM APL do?

--blake


On Sat, Apr 4, 2020 at 5:03 PM Rowan Cannaday  wrote:

> hello y'all, hope everyone is staying safe.
>
>   x ← 1 (2 3 (4 5))
>   (⊃⊃x)[2;3;] ← 6 7
>
>
> ===
> SEGMENTATION FAULT
>
> 
> -- Stack trace at main.cc:88
> 
> 0x7F032D7BABBB __libc_start_main
> 0x557F8B045425  main
> 0x557F8B1BE755   Workspace::immediate_execution(bool)
> 0x557F8B099A4BCommand::process_line()
> 0x557F8B09A45A Command::do_APL_expression(UCS_string&)
> 0x557F8B099AE8  Command::finish_context()
> 0x557F8B0A3698   Executable::execute_body() const
> 0x557F8B159D4CStateIndicator::run()
> 0x557F8B0DB23D Prefix::reduce_statements()
> 0x557F8B0DA17D  Prefix::reduce_MISC_F_B_()
> 0x557F8B0F1F4F   Bif_F12_PICK::eval_B(Value_P)
> 0x557F8B0EBB33Bif_F12_PICK::disclose(Value_P, bool)
> 0x557F8B0EB86A Bif_F12_PICK::compute_item_shape(Value_P, bool)
> 0x7F032DCD1520
> 0x557F8B04C4AB
> 
> 
>
> By the way, it works if you use an intermediary variable:
>
>   y←⊃⊃x
>   y[2;3;]
> 4 5
>   y[2;3;] ← 5 6
>   y
> 1 0
> 0 0
> 0 0
>
> 2 0
> 3 0
> 5 6
>
> Cheers,
>  - Rowan
>