I have a console app I'm working on that is having behavior I've never seen before: NULL pointer dereferences aren't causing SEGFAULT or any sort of exception. There's even nothing being printed in the output window of the debugger, suggesting that there's no exception at all being generated.
I have code that does the following:
istViewJobHistory.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
JobInformation newFragment = new JobInformation();
android.support.v4.app.FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.listViewJobHistory, newFragment);
transaction.addToBackStack(null);
transaction.commit();
}
});
pointer is definitely all zeros (I've printed it out, inspected it in the debugger, compared it to zero, etc).
This causes absolutely nothing untoward to happen and it merrily steps over it. I went to the exception dialog and turned on 'break on all thrown exceptions', and still nothing. I know null pointer references are undefined, but my experience to this date is that Visual Studio projects catch these, particularly in the debugger.
I highly suspect I've got some compiler setting fiddled with, but I have no clue what setting that might be. It should be a bog standard native console app, but the project settings have been under the control of an intern...
This is VS2010 ultimate, windows7-64bit, console app. I think it's win32, but it might be 64bit.
Anyways, anybody have any clues to check when I get to the office tomorrow?
答案 0 :(得分:0)
嗯,我觉得有点愚蠢,但我很放心,我并不疯狂。
显然,Windows7运行时环境只能封锁虚拟内存空间的第一个64KB,而我指向的结构元素已超过64K,所以
var myModule = function () {
//"private" variables:
var myPrivateVar = "01I can be accessed only from within YAHOO.myProject.myModule.";
//"private" method:
var myPrivateMethod = function () {
console.log("02I can be accessed only from within YAHOO.myProject.myModule");
}
return {
myPublicProperty: "I'm accessible as YAHOO.myProject.myModule.myPublicProperty.",
myPublicMethod: function () {
console.log("1I'm accessible as YAHOO.myProject.myModule.myPublicMethod.");
//Within myProject, I can access "private" vars and methods:
console.log("2"+myPrivateVar);
console.log("3"+myPrivateMethod());
//The native scope of myPublicMethod is myProject; we can
//access public members using "this":
console.log("4"+this.myPublicProperty);
}
};
}();
不会导致异常。这是一个不方便的巧合,我的类中唯一没有传递命令行参数时使用的元素是在一些非常大的工作缓冲区之后发生的状态变量。