ModularM
Modular16mo ago
16 replies
nairby

Is there something I’m not understanding about the Mojo memory model?

I hope this is an easy question and someone will know the obvious thing I'm doing wrong. I have this minimal example code that demonstrates an issue I’m having.

main.mojo:

from command_line_mod import process_command_line_args

fn init_system():

  process_command_line_args()

fn main():
  init_system()


command_line_mod.mojo:

var bundle_file_name: String = "test"

fn process_command_line_args():

  print("bundle_file_name = ", bundle_file_name)


If I build and run this with mojo build main.mojo; ./main I get a segmentation fault. Why?
Was this page helpful?