Bug 14408 - Values in parameter list become zero in called function
Summary: Values in parameter list become zero in called function
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2013-09-03 19:54 UTC by Ron Werbow
Modified: 2013-09-04 14:57 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Source code that shows the bug (994 bytes, application/octet-stream)
2013-09-03 19:54 UTC, Ron Werbow

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Ron Werbow 2013-09-03 19:54:43 UTC
Created attachment 4773 [details]
Source code that shows the bug

I have a program that works correctly under .Net 3.5.  However, under Mono valid values in a function call become zero in the called routine.  An example of the failure is attached.

In the example, the function test.Function takes 7 parameters.  The first 3 and last 1 retain their value correctly after the call.  However, the other three (IntPtr, int, int) all become zero.
Comment 1 Marek Safar 2013-09-04 05:39:39 UTC
This works for me with mono master and 3.2.1 and 2.10.9. Maybe it's architecture specific. Could you provide more details?
Comment 2 Ron Werbow 2013-09-04 10:50:33 UTC
I'm running on a Centos 6.3 system with Mono 3.2.1 and Monodevelop 4.0.12.  Is there a difference between Mono and Mono Master?
Comment 3 Zoltan Varga 2013-09-04 12:00:49 UTC
What is the output of mono --version ?
Comment 4 Ron Werbow 2013-09-04 12:24:51 UTC
Comment 5 Zoltan Varga 2013-09-04 12:55:42 UTC
What is the complete output of mono --version ? I.e. architecture, used gc, etc. ?
Comment 6 Ron Werbow 2013-09-04 13:00:52 UTC
[root@PER720-CENTOS-1 ~]# mono --version
Mono JIT compiler version 3.2.1 (tarball Wed Aug 21 01:39:24 PDT 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
[root@PER720-CENTOS-1 ~]#
Comment 7 Zoltan Varga 2013-09-04 13:07:59 UTC
How does the testcase fail ? Does the Marshal.FreeHGlobal () line throw a NullReferenceException ?
Comment 8 Ron Werbow 2013-09-04 13:30:18 UTC
No.  It's not a null refernce.  All parameters are passed by value and the values become zero.  So the function just doesn't work.  What I did was set a breakpoint at the call and verify that all parameter values were correct.  Then I stepped into the function and checked the values again.  Some of them were wrong.  I could then go back and fourth in the stack to the calling and called functions.  Parameters were still correct when calling, but still incorrect when receiving.
Comment 9 Zoltan Varga 2013-09-04 13:54:16 UTC
So this only happens when running under the debugger ?
Comment 10 Ron Werbow 2013-09-04 14:17:59 UTC
Perhaps that's the case.  I'll run some tests and cancel the bug report if it works outside of the debugger.

Comment 11 Ron Werbow 2013-09-04 14:57:28 UTC
The issue turned out to be a problem in Monodevelop.  Even in the debugger, if I don't stop and query the variables, the program works.