File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,25 @@ private List<CXUnsavedFile> CreateUnsavedFilesList(SourceFileInternal? indexFile
158
158
159
159
private void InitializeClang ( )
160
160
{
161
+ // Workaround for https://github.com/MochiLibraries/ClangSharp.Pathogen/issues/7
162
+ if ( OperatingSystem . IsLinux ( ) )
163
+ {
164
+ try
165
+ {
166
+ unsafe
167
+ {
168
+ [ DllImport ( "libc" ) ]
169
+ static extern int setenv ( byte * envname , byte * envval , int overwrite ) ;
170
+
171
+ fixed ( byte * nameP = Encoding . ASCII . GetBytes ( "LIBCLANG_DISABLE_CRASH_RECOVERY\0 " ) )
172
+ fixed ( byte * valueP = Encoding . ASCII . GetBytes ( "1\0 " ) )
173
+ { setenv ( nameP , valueP , 1 ) ; }
174
+ }
175
+ }
176
+ catch ( Exception ex )
177
+ { Console . Error . WriteLine ( $ "Exception while applying ClangSharp.Pathogen#7 workaround: { ex } ") ; }
178
+ }
179
+
161
180
if ( Environment . GetEnvironmentVariable ( "BIOHAZRD_CUSTOM_LIBCLANG_PATHOGEN_RUNTIME" ) is string customNativeRuntime )
162
181
{
163
182
LibClangSharpResolver . OverrideNativeRuntime ( customNativeRuntime ) ;
Original file line number Diff line number Diff line change @@ -271,5 +271,14 @@ public void ClangFindsSystemIncludes()
271
271
) ;
272
272
library . FindDeclaration < TranslatedFunction > ( "Test" ) ;
273
273
}
274
+
275
+ [ Fact ]
276
+ [ RelatedIssue ( "https://github.com/MochiLibraries/ClangSharp.Pathogen/issues/7" ) ]
277
+ public void ClangDoesntBreakNullReferenceException ( )
278
+ {
279
+ CreateLibrary ( "void Hello();" ) ;
280
+ object o = null ! ;
281
+ Assert . Throws < NullReferenceException > ( ( ) => o . GetHashCode ( ) ) ;
282
+ }
274
283
}
275
284
}
You can’t perform that action at this time.
0 commit comments