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
io.format causes segfault with i(X) parameter #88
Comments
Does your program work as expected if you compile with --no-optimize-format-calls? |
No, it also fails. (I'm using a different test program now) Without --no-optimize-format-calls:: MacBook-Pro-2% mmc --make format_test With --no-optimize-format-calls: MacBook-Pro-2% rm -r Mercury format_test format_test.mh format_test.err *** Mercury runtime: caught segmentation violation *** ` |
It looks like you have one of the low-level C grades as your default grade? Which one is it? Also, what C compiler (and version thereof) are you using? (I've tried the test program with macOS 10.12 using clang 4.2.1 -- clang 9.0.0 in Apples number -- with both the hlc.gc and none.gc grades and it works fine.) |
According to the -V output, the grade is hlc.gc. MERCURY_STDLIB_DIR=/usr/local/mercury-20.01/lib/mercury |
I just checked and it looks like the Apple number for clang is 11.0.0 (sorry I didn't put this in my previous remark): |
It works now. I upgraded XCode and command line tools and rebuilt mercury. Apparently there was a problem with the clang 11.0.0 and stack alignment. Other projects have reported similar issues. Clang 11.0.3 seems to work fine. Thanks, and apologies for the inconvenience. |
Could you please send us a link to someplace that describes those problems with clang 11.0.0? |
No problem. Here is the discussion that I found: Yesterday when I checked with lldb I got the stack alignment error they describe: MacBook-Pro-2% lldb format_test
libdyld.dylib`_dyld_fast_stub_entry: The steps for the fix were as follows:
|
When compiled with mercury-20.01 to the default grade on MacOS 10.15.4, the following line causes a segfault:
io.format("Successful test: %s has %d solutions\n", [s(Code), i(Solution)], !IO)
...
Successful test: 1 has *** Mercury runtime: caught segmentation violation *** This may have been caused by a stack overflow, due to unbounded recursion. exiting from signal handler zsh: segmentation fault ./count
The problems seems to be caused by the integer processing. I tried the later rotd releases and had the same problem, however, when compiled using the java grade, the program runs as expected.
Further, the problem seems to be only with integer and float values. Strings, that is s(X), work fine.
The text was updated successfully, but these errors were encountered: