Thanks. Your correction does appear to work without error.

“Length is count of bytes” remains subtle in the documentation without 
reference made to type.

https://code.jsoftware.com/wiki/Guides/DLLs/Memory_Management


> On Aug 13, 2022, at 5:26 PM, Elijah Stone <[email protected]> wrote:
> 
> mema takes a count of bytes, but memw and memr both take a count of items.  
> So if you want space for y integers, you need mema y*8 (or, if scrupulous, 
> mema y*2^2+IF64).
> 
>> On Sat, 13 Aug 2022, John Ference wrote:
>> 
>> Writing and reading integers to memory is non-deterministically in error,
>> producing variably incorrect results and segfaults:
>> 
>> 
>> One example which occurs about 20% of the time is:
>> 
>> 
>>  y =. 203
>> 
>>  pt=. mema y
>> 
>>  (y # 0) memw pt,0,y,4
>> 
>>  +/ memr pt,0,y,4
>> 
>> 140717552857408
>> 
>> NB. or other non-zero integer
>> 
>> 
>> 
>> Another example, this one which occurs on approximately 75% of runs is:
>> 
>> 
>>  wr=.{{
>> 
>> l=. y
>> 
>> pt=. mema l
>> 
>> (l # 0) memw pt,0,l,4
>> 
>> +/ memr pt,0,l,4
>> 
>> }}"0
>> 
>> 
>>  +/ wr i. 1e5
>> 
>> jconsole(81462,0x1145b5e00) malloc: Incorrect checksum for freed object
>> 0x7fb4ff00b200: probably modified after being freed.
>> 
>> Corrupt value: 0x0
>> 
>> jconsole(81462,0x1145b5e00) malloc: *** set a breakpoint in
>> malloc_error_break to debug
>> 
>> Abort trap: 6
>> 
>> 
>> 
>> 
>>  JVERSION
>> 
>> Engine: j904/j64avx/darwin
>> 
>> Beta-e: commercial/2022-07-16T19:27:13
>> 
>> Library: 9.04.03
>> 
>> Platform: Darwin 64
>> 
>> Installer: J904 install
>> 
>> InstallPath: /applications/j904
>> 
>> Contact: www.jsoftware.com
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to