You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Todd Farmer (Jira)" <ji...@apache.org> on 2022/07/12 14:05:02 UTC

[jira] [Assigned] (ARROW-7040) [C#] System.Memory Span.CopyTo - Crashes on Net Framework

     [ https://issues.apache.org/jira/browse/ARROW-7040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Todd Farmer reassigned ARROW-7040:
----------------------------------

    Assignee:     (was: Anthony Abate)

This issue was last updated over 90 days ago, which may be an indication it is no longer being actively worked. To better reflect the current state, the issue is being unassigned. Please feel free to re-take assignment of the issue if it is being actively worked, or if you plan to start that work soon.

> [C#] System.Memory  Span.CopyTo - Crashes on Net Framework 
> -----------------------------------------------------------
>
>                 Key: ARROW-7040
>                 URL: https://issues.apache.org/jira/browse/ARROW-7040
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C#
>    Affects Versions: 0.14.1, 0.15.0
>            Reporter: Anthony Abate
>            Priority: Blocker
>              Labels: pull-request-available
>          Time Spent: 6h 50m
>  Remaining Estimate: 0h
>
> The following code crashes on 8 cores.
> {code:java}
>         public async Task StringArrayBuilder_StressTest()
>         {
>             var wait = new List<Task>();            
>             for (int i = 0; i < 30; ++i)
>             {
>                 var data = Enumerable.Range(0, 1000).Select(x => $"Item {x + 1}").ToArray();                
>                 var t = Task.Run(() =>
>                 {
>                     for (int j = 0; j < 10000000; ++j)
>                     {
>                         var builder = new StringArray.Builder();
>                         builder.AppendRange(data);
>                     }
>                 });                
>                 wait.Add(t);
>             }            
>             await Task.WhenAll(wait);
>         } {code}
>  
> It does not happen with the primitive arrays.  (ie IntArrayBuilder)
> I suspect it is due to the offset array / and all the copy / resizing going on
>  
> Update - it seems that the problem is in the underlying *ArrowBuffer.Builder<T>*
> {code:java}
>          public async Task ValueBuffer_StressTest()
>         {
>             var wait = new List<Task>();            
>             for (int i = 0; i < 30; ++i)
>             {
>                 var data = Enumerable.Range(0, 1000).Select(x => $"Item {x + 1}").ToArray();                
>                 var t = Task.Run(() =>
>                 {
>                     for (int j = 0; j < 10000000; ++j)
>                     {
>                         ArrowBuffer.Builder<byte> ValueBuffer = new ArrowBuffer.Builder<byte>();                        
>                         foreach (var d in data)
>                         {
>                             ValueBuffer.Append(Encoding.UTF8.GetBytes(d));
>                         }
>                     }
>                 });                
>                 wait.Add(t);
>             }            
>             await Task.WhenAll(wait);
>         }{code}
>  
> Update 2:
> This is due to a confirmed bug in System.Memory - The implications are that Span.CopyTo needs to be removed / replaced. 
> This is method is used internally by ArrowBuffer so I can't work around this easily. 
> Solutions
>  # Change the code
>  ## Remove it out right (including disable span in FlatBuffer)
>  ## create a multi target nuget where the offending code has compile blocks #If (NETFRAMEWORK) - and disable span in FlatBuffers only for net framework build 
>  # wait for a System.Memory fix?
>  
> I suspect option 2 won't happen anytime soon.  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)