Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown at X (objc.dll) in ObjCWin32.exe: 0xC0000005: Access violation reading location X. #51

Open
TylerJaacks opened this issue Oct 10, 2024 · 9 comments

Comments

@TylerJaacks
Copy link

OS: Windows 11 Version 24H2 (OS Build 26100.1882)
IDE: Visual Studio 2022 Enterprise Preview
Version: Release 2023-12-28

Exception thrown at 0x00007FF9A3E128B4 (objc.dll) in ObjCWin32.exe: 0xC0000005: Access violation reading location 0x0000000000000038.

#include <Foundation/Foundation.h>

int main(int argc, char *argv[])
{
    NSLog(@"Hello Objective-C");

    return 0;
}

Happens on

NSLog(@"Hello Objective-C")
@triplef
Copy link
Member

triplef commented Oct 10, 2024

Which Clang version are you using? You’ll want to use Clang 16 or later.

If that’s already the case please provide a stack trace.

@TylerJaacks
Copy link
Author

clang version 17.0.6
Target: x86_64-unknown-windows-msvc
Thread model: posix
InstalledDir: C:\Users\tylerjaacks\AppData\Local\Programs\Swift\Toolchains\6.0.1+Asserts\usr\bin

There is no stack trace but here is the call stack.

>	objc.dll!00007ff8763b1038()	Unknown
 	0034003200300032()	        Unknown
 	002d00300031002d()	        Unknown

@triplef
Copy link
Member

triplef commented Oct 11, 2024

Can you try a debug build and/or running with LLDB to see if that gives you symbols?

@TylerJaacks
Copy link
Author

❯ lldb .\Template.exe
==== LLDB swift-healthcheck log. ===
This file contains the configuration of LLDB's embedded Swift compiler to help diagnosing module import and search path issues. The swift-healthcheck command is meant to be run *after* an error has occurred.
lldb version 17.0.6
Swift version 6.0.1 (swift-6.0.1-RELEASE)
(lldb) target create ".\\Template.exe"
(lldb) Current executable set to 'C:\GNUstep\x64\Template\x64\Debug\Template.exe' (x86_64).
(lldb) r
(lldb) Process 60760 launched: 'C:\GNUstep\x64\Template\x64\Debug\Template.exe' (x86_64)
Process 60760 stopped
* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x7ffa0e231038: Access violation reading location 0x00000038
    frame #0: 0x00007ffa0e231038 objc.dll`objc_msgSend + 24
objc.dll`objc_msgSend:
->  0x7ffa0e231038 <+24>: movq   0x38(%r10), %r10
    0x7ffa0e23103c <+28>: movq   %rax, -0x8(%rsp)
    0x7ffa0e231041 <+33>: movq   %rbx, -0x10(%rsp)
    0x7ffa0e231046 <+38>: movl   (%rdx), %eax
Target 0: (Template.exe) stopped.
(lldb)

@TylerJaacks
Copy link
Author

Ok I think this is the correct version of Clang with Visual Studio, the other was for Swift

clang version 17.0.3
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin

@TylerJaacks
Copy link
Author

Ok it seems to be a Visual Studio project file issue cause compiling from the command line with cl-clang.exe works.

@TylerJaacks
Copy link
Author

Ok so I see what the issue is.

I replaced the examples\ObjCWin32\ObjCWin32\ObjCWin32.mm with this

#include <Foundation/Foundation.h>

int main(int argc, char *argv[])
{
    NSLog(@"Hello Objective-C");
    return 0;
}

and that causes the crash.

@TylerJaacks
Copy link
Author

Ok so I created a new project instead of working of the example project.

I get this im not sure if this would be the correct output.

Unable to create time zone for name: 'America/Chicago'
(source 'function: 'GetTimeZoneInformation()'').

It seems that your operating system does not have a valid timezone name
configured (it could be that some other software has set a, possibly
ambiguous, timezone abbreviation rather than a name) ... please correct
that or override by setting a timezone name (such as 'Europe/London'
or 'America/Chicago').

You can override the timezone name by setting the 'Local Time Zone'
NSUserDefault via the 'defaults' command line utility, a Preferences
application, or some other utility.
eg "defaults write NSGlobalDomain 'Local Time Zone' 'Africa/Nairobi'"
See '(null)'
for the standard timezones such as 'GB-Eire' or 'America/Chicago'.
2024-10-14 01:26:24.108 ObjCExample[114360:48584] Using time zone with absolute offset 0.
2024-10-14 01:26:24.104 ObjCExample[114360:48584] Hello Objective-C

D:\Documents\Visual Studio 2022\Projects\ObjCExample\x64\Debug\ObjCExample.exe (process 114360) exited with code 0 (0x0).
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

@triplef
Copy link
Member

triplef commented Oct 14, 2024

I replaced the examples\ObjCWin32\ObjCWin32\ObjCWin32.mm with this
...
and that causes the crash.

If you want to use main() with the example you’ll need to change the subsystem type to "Console" in the project settings under Linker > System. With that change and replacing ObjCWin32.mm it worked fine for me using the latest build from GitHub. I couldn’t reproduce it, but maybe your crash came from using the wrong subsystem?

The timezone warnings are currently expected in some cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants