Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

原文地址: http://archives.devshed.com/forums/net-206/prb-cannot-evaluate-expression-because-a-thread-is-stopped-at-2339421.html

 

  # 1  
Old June 20th, 2007, 05:00 PM
Mike Andrews
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

Guys,

I'm getting this in the VS2005 IDE when I try to debug my code. I'm really
at a loss to figure this one out.

"Cannot evaluate expression because a thread is stopped at a point where
garbage collection is impossible, possibly because the code is optimized."

This does not occur until a method with a particular line of code is
entered. this method is entered by the debugger, any object more
complex than the intrinsic data types such as ints and strings cause this
error to be displayed.

The methods are as such:



//Variables are readable before this line
this.GridHelper.MarContainer = new MarContainer(myGuid, ThirtyDay,
this.GridHelper.StartDate);
//And after this line


public class GridHelper {

public GridHelper(Guid guid, MarType type, DateTime date){

//Variables are readable before this line
Load(guid, type, date, null);
//But not after this line
}

private void Load(Guid guid, MarType type, DateTime startDate,
TransactionContext transaction){
//Nothing is readable in here except intrinsic data types

//This is the line, that when commented out, keeps the ability to
display values working
_groups.Load(details, type, startDate);
}

}

_groups is a variable that references a custom class (that inherits directly
from S) that has no "special" functionality in it whatsoever.

Any suggestions or ideas?

Thanks,
Mike


This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
  # 2  
Old June 21st, 2007, 07:30 AM
J. Merrill
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

Well, the class referenced by _groups must have a method called Load. What's in it? Have you tried commenting out different lines in the Load method to see what no longer "keeps the ability to display values working"?

At 04:33 PM 6/20/2007, Mike Andrews wrote (in part)

private void Load(Guid guid, MarType type, DateTime startDate,
>TransactionContext transaction){

//Nothing is readable in here except intrinsic data types

//This is the line, that when commented out, keeps the ability to
>display values working

_groups.Load(details, type, startDate);
}
>
>}
>
>_groups is a variable that references a custom class (that inherits directly
>from S) that has no "special" functionality in it whatsoever.


J. Merrill / Analytical Software Corp


This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
  # 3  
Old June 21st, 2007, 12:01 PM
Mike Andrews
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

I think I've discovered the issue and after talking with a Microsoft
technical support rep.
The rep didn't have an answer, but made a reference to the number of
parameters which led me to look further.

The issue seems to be the total size of all parameters passed in to the
method.
The "details" parameter in the _groups.Load() method is a struct.
The struct itself is quite large in size with about 30 fields that contain
DataTables, DataRelations and DataRows.
When I converted the struct to a class, the problem disappeared. It seems
to be that the struct cannot be passed byval like a class when the size of
the struct is greater than some [unknown] value.

A very weird problem indeed.

Thanks,
Mike


6/21/07, J. Merrill <jvm_cop (AT) spamcop (DOT) netwrote:
>

Well, the class referenced by _groups must have a method called
Load. What's in it? Have you tried commenting out different lines in the
Load method to see what no longer "keeps the ability to display values
working"?
>

At 04:33 PM 6/20/2007, Mike Andrews wrote (in part)
>

private void Load(Guid guid, MarType type, DateTime startDate,
>TransactionContext transaction){

//Nothing is readable in here except intrinsic data types

//This is the line, that when commented out, keeps the ability to
>display values working

_groups.Load(details, type, startDate);
}
>
>}
>
>_groups is a variable that references a custom class (that inherits

directly
>from S) that has no "special" functionality in it whatsoever.
>

J. Merrill / Analytical Software Corp
>

This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>


This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
  # 4  
Old June 21st, 2007, 12:01 PM
Paul van Brenk
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

Uh A struct is always passed by value (ie. Copied). A class is passed by reference (just the pointer) So yeah, I can imagine copying a struct with the size you describe could be a problem for the GC.

Message
From: Discussion of advanced .NET topics. [mailto:ADVANCED-DTNET (AT) DISCUSS (DOT) DEVELP.CM] Behalf Mike Andrews
Sent: Thursday, June 21, 2007 17:47
To: ADVANCED-DTNET (AT) DISCUSS (DOT) DEVELP.CM
Subject: Re: [ADVANCED-DTNET] PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible

I think I've discovered the issue and after talking with a Microsoft
technical support rep.
The rep didn't have an answer, but made a reference to the number of
parameters which led me to look further.

The issue seems to be the total size of all parameters passed in to the
method.
The "details" parameter in the _groups.Load() method is a struct.
The struct itself is quite large in size with about 30 fields that contain
DataTables, DataRelations and DataRows.
When I converted the struct to a class, the problem disappeared. It seems
to be that the struct cannot be passed byval like a class when the size of
the struct is greater than some [unknown] value.

A very weird problem indeed.

Thanks,
Mike


6/21/07, J. Merrill <jvm_cop (AT) spamcop (DOT) netwrote:
>

Well, the class referenced by _groups must have a method called
Load. What's in it? Have you tried commenting out different lines in the
Load method to see what no longer "keeps the ability to display values
working"?
>

At 04:33 PM 6/20/2007, Mike Andrews wrote (in part)
>

private void Load(Guid guid, MarType type, DateTime startDate,
>TransactionContext transaction){

//Nothing is readable in here except intrinsic data types

//This is the line, that when commented out, keeps the ability to
>display values working

_groups.Load(details, type, startDate);
}
>
>}
>
>_groups is a variable that references a custom class (that inherits

directly
>from S) that has no "special" functionality in it whatsoever
>

J. Merrill / Analytical Software Corp
>


This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>

This list is hosted by DevelopMentor(r) http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
  # 5  
Old June 21st, 2007, 12:01 PM
Mike Andrews
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

Yes.
And it makes sense now. I just wasn't thinking along those lines until the
MS guy said something about it and I had time to think about it for a while.
It's always something. LL.
I didn't equate the GC having issues with debugger and the size of the
struct.

6/21/07, Paul van Brenk <paul.van.brenk (AT) tamtam (DOT) nlwrote:
>

Uh A struct is always passed by value (ie. Copied). A class is passed by
reference (just the pointer) So yeah, I can imagine copying a struct with
the size you describe could be a problem for the GC.
>

Message
From: Discussion of advanced .NET topics. [mailto:
ADVANCED-DTNET (AT) DISCUSS (DOT) DEVELP.CM] Behalf Mike Andrews
Sent: Thursday, June 21, 2007 17:47
To: ADVANCED-DTNET (AT) DISCUSS (DOT) DEVELP.CM
Subject: Re: [ADVANCED-DTNET] PRB: Cannot evaluate expression because a
thread is stopped at a point where garbage collection is impossible
>

I think I've discovered the issue and after talking with a Microsoft
technical support rep.
The rep didn't have an answer, but made a reference to the number of
parameters which led me to look further.
>

The issue seems to be the total size of all parameters passed in to the
method.
The "details" parameter in the _groups.Load() method is a struct.
The struct itself is quite large in size with about 30 fields that contain
DataTables, DataRelations and DataRows.
When I converted the struct to a class, the problem disappeared. It seems
to be that the struct cannot be passed byval like a class when the size of
the struct is greater than some [unknown] value.
>

A very weird problem indeed.
>

Thanks,
Mike
>
>

6/21/07, J. Merrill <jvm_cop (AT) spamcop (DOT) netwrote:
>

Well, the class referenced by _groups must have a method called
Load. What's in it? Have you tried commenting out different lines in
the
Load method to see what no longer "keeps the ability to display values
working"?
>

At 04:33 PM 6/20/2007, Mike Andrews wrote (in part)
>

private void Load(Guid guid, MarType type, DateTime startDate,
>TransactionContext transaction){

//Nothing is readable in here except intrinsic data types

//This is the line, that when commented out, keeps the ability to
>display values working

_groups.Load(details, type, startDate);
}
>
>}
>
>_groups is a variable that references a custom class (that inherits

directly
>from S) that has no "special" functionality in it

whatsoever.
>

J. Merrill / Analytical Software Corp

This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>

This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>

This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>

This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
  # 6  
Old June 21st, 2007, 05:00 PM
Mike Andrews
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

Does anyone know the maximum size of a struct that can be used in the
Framework without having these issues?

Thanks,
Mike


6/21/07, Mike Andrews <outdoor.jellyroll (AT) gmail (DOT) comwrote:
>

Yes.
And it makes sense now. I just wasn't thinking along those lines until
the MS guy said something about it and I had time to think about it for a
while.
It's always something. LL.
I didn't equate the GC having issues with debugger and the size of the
struct.
>

6/21/07, Paul van Brenk <paul.van.brenk (AT) tamtam (DOT) nlwrote:
>

Uh A struct is always passed by value (ie. Copied). A class is passed
by reference (just the pointer) So yeah, I can imagine copying a struct
with the size you describe could be a problem for the GC.
>

Message
From: Discussion of advanced .NET topics. [mailto:
ADVANCED-DTNET (AT) DISCUSS (DOT) DEVELP.CM] Behalf Mike Andrews
Sent: Thursday, June 21, 2007 17:47
To: ADVANCED-DTNET (AT) DISCUSS (DOT) DEVELP.CM
Subject: Re: [ADVANCED-DTNET] PRB: Cannot evaluate expression because a
thread is stopped at a point where garbage collection is impossible
>

I think I've discovered the issue and after talking with a Microsoft
technical support rep.
The rep didn't have an answer, but made a reference to the number of
parameters which led me to look further.
>

The issue seems to be the total size of all parameters passed in to the
method.
The "details" parameter in the _groups.Load() method is a struct.
The struct itself is quite large in size with about 30 fields that
contain
DataTables, DataRelations and DataRows.
When I converted the struct to a class, the problem disappeared. It
seems
to be that the struct cannot be passed byval like a class when the size
of
the struct is greater than some [unknown] value.
>

A very weird problem indeed.
>

Thanks,
Mike
>
>

6/21/07, J. Merrill <jvm_cop (AT) spamcop (DOT) netwrote:
>

Well, the class referenced by _groups must have a method called
Load. What's in it? Have you tried commenting out different lines in
the
Load method to see what no longer "keeps the ability to display values
working"?
>

At 04:33 PM 6/20/2007, Mike Andrews wrote (in part)
>

private void Load(Guid guid, MarType type, DateTime startDate,
>TransactionContext transaction){

//Nothing is readable in here except intrinsic data types

//This is the line, that when commented out, keeps the ability to
>display values working

_groups.Load(details, type, startDate);
}
>
>}
>
>_groups is a variable that references a custom class (that inherits

directly
>from S) that has no "special" functionality in it

whatsoever.
>

J. Merrill / Analytical Software Corp
>


This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>

This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>

This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>

This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
  # 7  
Old June 21st, 2007, 05:30 PM
Chris Anderson
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

Does anyone know the maximum size of a struct that can be used in the
Framework without having these issues?

The general rule of thumb is : If you're worrying about the maximum size
of a struct, it's already too big!

Structs were designed to be used for small lightweight data types (like
Point, Rectangle, etc)


This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
  # 8  
Old June 21st, 2007, 06:00 PM
Mike Andrews
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

Very true.
I was just curious.
I'm generally more sparing on my use of structs.

Nevertheless, I still want to know the maximum size of a struct or if there
is no size limit, the optimal size of a struct.


6/21/07, Chris Anderson <Chris (AT) activeide (DOT) comwrote:
>

Does anyone know the maximum size of a struct that can be used in the
Framework without having these issues?
>

The general rule of thumb is : If you're worrying about the maximum size
of a struct, it's already too big!
>

Structs were designed to be used for small lightweight data types (like
Point, Rectangle, etc)
>


This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>



This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
  # 9  
Old June 21st, 2007, 07:00 PM
Chris Anderson
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

I've been trying to look for a cite, but can only tell you that I was
told by a instructor (albeit a SQL Server 2005 one) anything bigger than
about 150 bytes was too big (remembering that a reference to a
DataTable, etc was only the size of the *reference* and not the size of
the data table contents, etc), but really it depends on usage IM

cite I *can* find is that "Unless you need reference type semantics,
a class that is smaller than 16 bytes may be more efficiently handled by
the system as a struct"

(vs.71).aspx

Not that that helps of course :-)



Message
From: Discussion of advanced .NET topics. [mailto:ADVANCED-
DTNET (AT) DISCUSS (DOT) DEVELP.CM] Behalf Mike Andrews
Sent: 22 June 2007 00:01
To: ADVANCED-DTNET (AT) DISCUSS (DOT) DEVELP.CM
Subject: Re: [ADVANCED-DTNET] PRB: Cannot evaluate expression because
a thread is stopped at a point where garbage collection is
impossible

Very true.
I was just curious.
I'm generally more sparing on my use of structs.

Nevertheless, I still want to know the maximum size of a struct or if
there
is no size limit, the optimal size of a struct.


6/21/07, Chris Anderson <Chris (AT) activeide (DOT) comwrote:
>

Does anyone know the maximum size of a struct that can be used in
the
Framework without having these issues?
>

The general rule of thumb is : If you're worrying about the maximum
size
of a struct, it's already too big!
>

Structs were designed to be used for small lightweight data types
(like
Point, Rectangle, etc)
>


This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>



This list is hosted by DevelopMentor(r) http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com



This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
  # 10  
Old June 25th, 2007, 08:30 AM
Mike Andrews
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PRB: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible...

Thank you Chris.

I think the sum total sizes of the "references" for all the objects in the
struct and the additional parameters on the method was greater than 256
bytes.
I got word back from MS on this issue:

"generally speaking, when the total size of the arguments passed to a
callee function is larger than 256 bytes, JIT will make the caller function
partially interruptible. In a partially interruptible code, not every
location in the code is a GC safe point. Therefore, it might be unsafe to
evaluate expression at certain locations. When this happens you get [the
error message]."

So it seems that even since the fields were references, the sum of all them
exceeded the 256 byte *limit* for the debugger.


6/21/07, Chris Anderson <Chris (AT) activeide (DOT) comwrote:
>

I've been trying to look for a cite, but can only tell you that I was
told by a instructor (albeit a SQL Server 2005 one) anything bigger than
about 150 bytes was too big (remembering that a reference to a
DataTable, etc was only the size of the *reference* and not the size of
the data table contents, etc), but really it depends on usage IM
>

cite I *can* find is that "Unless you need reference type semantics,
a class that is smaller than 16 bytes may be more efficiently handled by
the system as a struct"
>

(vs.71).aspx
>

Not that that helps of course :-)
>
>
>

Message
From: Discussion of advanced .NET topics. [mailto:ADVANCED-
DTNET (AT) DISCUSS (DOT) DEVELP.CM] Behalf Mike Andrews
Sent: 22 June 2007 00:01
To: ADVANCED-DTNET (AT) DISCUSS (DOT) DEVELP.CM
Subject: Re: [ADVANCED-DTNET] PRB: Cannot evaluate expression because
a thread is stopped at a point where garbage collection is
impossible
>

Very true.
I was just curious.
I'm generally more sparing on my use of structs.
>

Nevertheless, I still want to know the maximum size of a struct or if
there
is no size limit, the optimal size of a struct.
>
>

6/21/07, Chris Anderson <Chris (AT) activeide (DOT) comwrote:
>

Does anyone know the maximum size of a struct that can be used in
the
Framework without having these issues?
>

The general rule of thumb is : If you're worrying about the maximum
size
of a struct, it's already too big!
>

Structs were designed to be used for small lightweight data types
(like
Point, Rectangle, etc)
>


This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>
>


This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>
>


This list is hosted by DevelopMentor(r) http://www.develop.com
>

View archives and manage your subscription(s) at
http://discuss.develop.com
>



This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

 
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值