question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullReferenceException when using AsyncPool

See original GitHub issue

I’m using FasterWrapper as suggested by https://github.com/microsoft/FASTER/issues/780#issuecomment-1383267812 But when running the following code, which checkpoints from multiple threads, I’m receving a NullReferenceException at var status = session.Upsert(key, value);

Can you please explain why?

var faster = new FasterWrapper<long, long>(isRefType: false, useLargeLog: false, useOsReadBuffering: false);
await Task.WhenAll(Enumerable.Range(0, 2).Select(async i =>
{
    faster.Upsert(i, i);
    await faster.Store.TakeHybridLogCheckpointAsync(CheckpointType.FoldOver);
}));

I’ve also noticed in the synchronous variation of methods like Upsert in FasterWrapper, _sessionPool.GetAsync().GetAwaiter().GetResult() is being used instead of the synchronous _sessionPool.Get(), is there reason for that?

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
badrishccommented, Jan 18, 2023
0reactions
wassim-kcommented, Jan 18, 2023

Reproduction:

  • Checkout AsyncStress playground
  • Expose public FasterKV<Key, Value> Store => _store; from FasterWrapper<Key, Value>
  • Replace Program’s Main method with above code as is.

Exception:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at FASTER.core.ClientSession`6.InternalFasterSession.TryLockEphemeralExclusive(RecordInfo& recordInfo)
   at AsyncStress.FasterWrapper`2.Upsert(Key key, Value value) in C:\Code\AsyncStress\FasterWrapper.cs:line 87
   at AsyncStress.Program.<>c__DisplayClass10_0.<<Main>b__0>d.MoveNext() in C:\Code\AsyncStress\Program.cs:line 70
--- End of stack trace from previous location ---
   at AsyncStress.Program.Main(String[] args) in C:\Code\AsyncStress\Program.cs:line 68
   at AsyncStress.Program.<Main>(String[] args)

The issue happens in v2.2.0 and v2.3.0 but not in v.2.1.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does async await throw a NullReferenceException?
Exception thrown inside killed my app with the NullReferenceException bec/ the method it was called from no longer existed.
Read more >
C# Task - LazyAsyncResult - NullReferenceException
You are using async/await so when something goes wrong inside the auto-generated code to support this the debugger throws you into the framework ......
Read more >
Async/Await Calls Gotcha with the CSharp ? Null Propagator
The first version works because null is a valid result for an expected result of a void method, or no result value from...
Read more >
NullReferenceException when running an async test for . ...
After upgrading my .NET Core project from NUnit 3.5 to NUnit 3.6, I noticed that a failing Assert.That in an async test produces...
Read more >
System.NullReferenceException is thrown when a ...
Hi Support,. An System.NullReferenceException: 'Object reference not set to an instance of an object.' is thrown by RichEditDocumentServer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found