-
Notifications
You must be signed in to change notification settings - Fork 10
Example fails with SIGSEGV on MacOS with Nim 2.2.2 and default orc memory manager #53
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
Comments
Thanks, I’ll need to investigate and see where it’s going wrong.
On Sun, 9 Feb 2025, at 17:25, martin-c wrote:
The first example
import serial
for port in listSerialPorts():
echo port
compile with
`nim c --stacktrace:on example.nim`
Compilation works es expected. But running the produced binary results in
`Traceback (most recent call last)
/Users/martin/.nimble/pkgs2/serial-1.2.0-85079d0e3a6e3f1478357c016e03308b8ede3a05/serial/private/utils/list_serialports_mac.nim(96) example
/Users/martin/.nimble/pkgs2/serial-1.2.0-85079d0e3a6e3f1478357c016e03308b8ede3a05/serial/private/utils/list_serialports_mac.nim(84) getDeviceName
/usr/local/Cellar/nim/2.2.2/nim/lib/system/arc.nim(188) nimRawDispose
/usr/local/Cellar/nim/2.2.2/nim/lib/system/alloc.nim(1165) dealloc
/usr/local/Cellar/nim/2.2.2/nim/lib/system/alloc.nim(1063) rawDealloc
/usr/local/Cellar/nim/2.2.2/nim/lib/system/alloc.nim(815) addToSharedFreeListBigChunks
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
`
… Compiling with `--mm:refc` creates binary which works, but no serial ports are listed. (MacOS 15.3)
—
Reply to this email directly, view it on GitHub <#53>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAFW24NUZDD34LM6ZQDZWM32O6FRLAVCNFSM6AAAAABWZBAPKSVHI2DSMVQWIX3LMV43ASLTON2WKOZSHA2DAOBSGYYTENQ>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
As an experiment, I've created the same code in Swift, and it compiles and runs fine there. I'm trying to work out what Nim is doing differently, but I suspect it's something related to ORC. Example Swift implementation: import Foundation
func listSerialPorts() {
var it: io_iterator_t = io_iterator_t()
let kernResult = withUnsafeMutablePointer(to: &it) { itPtr in
IOServiceGetMatchingServices(
kIOMainPortDefault,
IOServiceMatching("IOSeriaolBSDClient"),
itPtr
)
}
if kernResult == KERN_SUCCESS {
defer {
IOObjectRelease(it)
}
while IOIteratorIsValid(it) != 0 {
let service = IOIteratorNext(it)
if service == 0 {
break
}
let key = CFStringCreateWithCString(
kCFAllocatorDefault,
"IOCalloutDevice",
kCFStringEncodingASCII
)
let cfContainer = IORegistryEntryCreateCFProperty(
service,
key,
kCFAllocatorDefault,
0
)
if let cfContainer {
let name = CFStringGetCStringPtr((cfContainer as! CFString), kCFStringEncodingASCII)
print(String(cString: name!))
}
}
}
}
listSerialPorts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The first example
compile with
nim c --stacktrace:on example.nim
Compilation works es expected. But running the produced binary results in
Compiling with
--mm:refc
creates binary which works, but no serial ports are listed. (MacOS 15.3)The text was updated successfully, but these errors were encountered: