File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 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
158158
159159 private void InitializeClang ( )
160160 {
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+
161180 if ( Environment . GetEnvironmentVariable ( "BIOHAZRD_CUSTOM_LIBCLANG_PATHOGEN_RUNTIME" ) is string customNativeRuntime )
162181 {
163182 LibClangSharpResolver . OverrideNativeRuntime ( customNativeRuntime ) ;
Original file line number Diff line number Diff line change @@ -271,5 +271,14 @@ public void ClangFindsSystemIncludes()
271271 ) ;
272272 library . FindDeclaration < TranslatedFunction > ( "Test" ) ;
273273 }
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+ }
274283 }
275284}
You can’t perform that action at this time.
0 commit comments