473,395 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Pinvoke question: Am I causing this stack overflow?

Hi, TIA for any help.
(Thanks, Mattias Sjögren for your help yesterday! )

I am developing a C# wrapper for a 3rd party API. It processes buffers from
a video stream (file) and is structured where the initialization function
passes in two callback methods (my code) that the API calls to successively
read and write buffers. The C++ sample I am modeling this after works and
processes thousands of buffers, but when interface to my C# wrapper the API
gets a stack overflow every time the 18th buffer is read and the SUCCCESS
status is returned from the callback.

Q: Is there somethng in the way I am calling/being called by pinvoke that
is causing this stack overflow? I am attaching two posts
1) Facade class that calls the native methods (TpFacade.cs)
2) Driver class that calls the facade class. (ProcessStream.cs)

The stack overflow occurs when the GetStreamBuf method returns SUCCESS for
the 18th time.

Thanks for any suggestions!

+tom allen
Cupertino, CA.
Aug 31 '07 #1
2 1952

"Tom Allen" <tc**@pacbell.net.(nospam)wrote in message
news:89**********************************@microsof t.com...
Hi, TIA for any help.
(Thanks, Mattias Sjögren for your help yesterday! )

I am developing a C# wrapper for a 3rd party API. It processes buffers
from
a video stream (file) and is structured where the initialization function
passes in two callback methods (my code) that the API calls to
successively
read and write buffers. The C++ sample I am modeling this after works and
processes thousands of buffers, but when interface to my C# wrapper the
API
gets a stack overflow every time the 18th buffer is read and the SUCCCESS
status is returned from the callback.

Q: Is there somethng in the way I am calling/being called by pinvoke that
is causing this stack overflow? I am attaching two posts
1) Facade class that calls the native methods (TpFacade.cs)
2) Driver class that calls the facade class. (ProcessStream.cs)

The stack overflow occurs when the GetStreamBuf method returns SUCCESS for
the 18th time.

Thanks for any suggestions!

You didn't specify a calling convention for the delegate types as far as I
can see, so you might be trashing your caller's stack (actually trashing his
EBP, ESP registers).
>
+tom allen
Cupertino, CA.


Sep 4 '07 #2
Ben,

Thanks much for the reply, and for taking the time to scan the code. Your
suggestion makes sense.

Sadly, today was my last day on this contract. I have forwarded the
information to my boss and I hope she will be able to test it out and post a
reply to this thread. Thanks again.

+tom allen
Cupertino, CA.
"Ben Voigt [C++ MVP]" wrote:
>
"Tom Allen" <tc**@pacbell.net.(nospam)wrote in message
news:89**********************************@microsof t.com...
Hi, TIA for any help.
(Thanks, Mattias Sjögren for your help yesterday! )

I am developing a C# wrapper for a 3rd party API. It processes buffers
from
a video stream (file) and is structured where the initialization function
passes in two callback methods (my code) that the API calls to
successively
read and write buffers. The C++ sample I am modeling this after works and
processes thousands of buffers, but when interface to my C# wrapper the
API
gets a stack overflow every time the 18th buffer is read and the SUCCCESS
status is returned from the callback.

Q: Is there somethng in the way I am calling/being called by pinvoke that
is causing this stack overflow? I am attaching two posts
1) Facade class that calls the native methods (TpFacade.cs)
2) Driver class that calls the facade class. (ProcessStream.cs)

The stack overflow occurs when the GetStreamBuf method returns SUCCESS for
the 18th time.

Thanks for any suggestions!


You didn't specify a calling convention for the delegate types as far as I
can see, so you might be trashing your caller's stack (actually trashing his
EBP, ESP registers).

+tom allen
Cupertino, CA.


Sep 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Aguilar, James | last post by:
Hello all, To begin, yes, this -is- a homework assignment. However, it is for my Algorithms class, and my instructor has given us explicit permission to use "expert" groups like newsgroups, so...
4
by: Victor | last post by:
Hello, I've got a situation in which the number of (valid) recursive calls I make will cause stack overflow. I can use getrlimit (and setrlimit) to test (and set) my current stack size. ...
4
by: Michael Thomas Cassady | last post by:
I know my subject wasn't the best but I hope people still look at this. I know that this is probably compiler and implementation dependent and that this is a standard c discussion group but can...
2
by: David W. Walker | last post by:
I am attempting to port a C code that runs OK on a number of Linux and Unix machines to Windows XP using Visual Studio C++. I have set the program up as a console application, but when I try to run...
4
by: Geordie | last post by:
Hi, I'm in the process of converting a production VS 2003 application to VS 2005. To simplify the conversion I'm converting a small piece at a time and then unit testing the code to confirm it...
7
by: amit.atray | last post by:
Environement : Sun OS + gnu tools + sun studio (dbx etc) having some Old C-Code (ansi + KR Style) and code inspection shows some big size variable (auto) allocated (on stack) say for ex. char...
1
by: gregarican | last post by:
A couple of days ago I was debating about whether to use C++/CLI or C# 2005's PInvoke in order to tie in my VS 2005 app with a legacy csta32.dll file. So far I have tried to call one method out of...
8
by: =?Utf-8?B?bWFyaw==?= | last post by:
consider: Int64 steps = 0; public Int64 recurse(double A) { steps += 1; A = A/2; try { A = recurse(A); }
3
by: Joey | last post by:
Hello guys, I am currently working on a fairly complex asp.net project using C#, VS2005, and several third-party components. I have a question about how to remedy a problem with it and maybe...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.