[Mono-dev] Mono embeded : NullReferenceException for a lock on a non-null object

Damien maitredede at gmail.com
Mon Jun 26 02:24:23 UTC 2017


Hi,

Sorry for dual posting with mono-list, but it seams that my problem is
tricky, I have also appended more info.

I am embedding mono in a qt application on Windows, and when executing
code, I have a SIGSEGV in managed code, that is a NullReferenceException,
but my variable is not null.

I am on Windows 10 x64.
I have installed Mono 5.0.1 (Visual Studio built mono) x86.
I code on Qt 5.3 with MinGW x86.

I have a native method that calls a managed method :
mono_runtime_invoke(method, obj, args, &exceptionObject).

In my managed method, I have a "lock" statement :
lock(this.myVar) { ... }

The SIGSEGV (or NullReferenceException) is raised only when the native
method is called on the second time. When called the first time, it works
well.
Between the two calls, nothing has changed.


I have refactored my code : the problem does not seam to come from the lock
statement, but from the underlying variable.
In my original case, "myVar" was a dictionary. In my refactored code, it is
a List<T>.
I have dumped the list items count.
When my method is called the first time, I have the good items count value.
When called the second time, the item count is an abberation, value is :
-259715328.

What can it mean ?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20170626/4948252b/attachment.html>


More information about the Mono-devel-list mailing list