Skip to content

Instantly share code, notes, and snippets.

@jasonroelofs
Last active February 23, 2025 06:24
Show Gist options
  • Save jasonroelofs/6453cc270ab8c60fca72029b47e6f7d7 to your computer and use it in GitHub Desktop.
Save jasonroelofs/6453cc270ab8c60fca72029b47e6f7d7 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -ex
PREFIX=[where ruby is installed]
clang++ -I$PREFIX/include/ruby-3.4.0/arm64-darwin24 -I$PREFIX/include/ruby-3.4.0 -L$PREFIX/lib -lruby.3.4 test.cpp
#include <ruby.h>
// This SEGFAULTs
int main(int argc, char** argv)
{
ruby_init();
ruby_init_loadpath();
char* options[] = { "-e;" };
ruby_options(2, options);
}
#include <ruby.h>
// This does not!
int main(int argc, char** argv)
{
RUBY_INIT_STACK;
ruby_init();
ruby_init_loadpath();
char* options[] = { "-e;" };
ruby_options(2, options);
}
@colin-i
Copy link

colin-i commented Feb 23, 2025

Not adding NULL at first options?
char* options[] = {NULL, "-e;" }; ruby_options(2, options);
Here this is not ok:
char* options[] = {"-e;" }; ruby_options(2, options);

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