octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54170] java.lang.String.toCharArray result in


From: Andrew Janke
Subject: [Octave-bug-tracker] [bug #54170] java.lang.String.toCharArray result incorrect conversion to char matrix
Date: Sun, 24 Jun 2018 15:54:34 -0400 (EDT)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36

Follow-up Comment #5, bug #54170 (project octave):

Similar issue on 4.4.0 / macOS. It produces what to me is an unexpected
string, and crashes.


$ octave
GNU Octave, version 4.4.0
[...]
Octave was configured for "x86_64-apple-darwin17.6.0".
[...]

octave:1> str=javaObject('java.lang.String', 'i am ............. here');
octave:2> str1=str.toCharArray
str1 =

i



a

m



.

.

.

.

.

.

.

octave:3> exit
fatal: caught signal Segmentation fault: 11 -- stopping myself...
[1]    47686 segmentation fault  octave


That crash is reproducible; happens every time I do this.

I also get a malloc error sometimes, but this one is not as reproducible. It
happens semi-consistently if I have used the up-arrow to retrieve the "str="
and "str1=" commands from my command history.


octave:1> str=javaObject('java.lang.String', 'i am ............. here')
str =

<Java object: java.lang.String>

octave:2> format compact
octave:3> str=javaObject('java.lang.String', 'i am ............. here')
str =
<Java object: java.lang.String>

octave:4> str1 = str.toCharArray
octave-gui(30948,0x70000b717000) malloc: *** error for object 0x7f9d3759f8c8:
incorrect checksum for freed object - object was probably modified after being
freed.
*** set a breakpoint in malloc_error_break to debug
fatal: caught signal Abort trap: 6 -- stopping myself...
[1]    30948 abort      octave


That double-spacing with only half the characters recovered does look like an
issue converting 2-byte Java UTF-16 chars to 1-byte Octave chars. Note that
those blanks are zeros, not spaces.



octave:3> double(str1')
ans =

 Columns 1 through 13:

   105     0    32     0    97     0   109     0    32     0    46     0   
46

 Columns 14 through 21:

     0    46     0    46     0    46     0    46



This probably works fine in Matlab because Matlab chars are 2-byte UTF-16
chars.

What *are* the expected semantics for converting Java `char`s to Octave
`char`s?

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54170>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]