modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
23.29k stars 2.59k forks source link

[BUG]: Empty strings concat raises `(os/kern) failure (5)` sometimes(!) #1919

Open toiletsandpaper opened 8 months ago

toiletsandpaper commented 8 months ago

Bug description

I've noticed, that when I'm trying to concatenate long string - my program crashes, but only sometimes! IDK why and I can't debug it. But when I try to remove this part of the code (and some commented below) https://github.com/toiletsandpaper/mojo_zlib_classification/blob/0922c6b7b54946c1fea21c5fa3f96b6142d26e32/main.mojo#L89 - everything works fine.

Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes.
Stack dump:
0.      Program arguments: mojo run main.mojo
#0 0x0000000102d2cfd8 llvm_strlcpy (/Users/toiletsandpaper/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x1000ccfd8)
#1 0x0000000102d2b138 llvm_strlcpy (/Users/toiletsandpaper/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x1000cb138)
#2 0x0000000102d2d678 llvm_strlcpy (/Users/toiletsandpaper/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x1000cd678)
#3 0x000000018b67da24 (/usr/lib/system/libsystem_platform.dylib+0x18046da24)
#4 0x0000000280004670 
#5 0x00000001030ca5a8 llvm_strlcpy (/Users/toiletsandpaper/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x10046a5a8)
#6 0x0000000102c81e94 _mh_execute_header (/Users/toiletsandpaper/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x100021e94)
#7 0x0000000102c65994 _mh_execute_header (/Users/toiletsandpaper/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x100005994)
#8 0x000000018b2cd0e0 
[85342:10397647:20240309,120826.006747:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)

Steps to reproduce

You can clone commit with this https://github.com/toiletsandpaper/mojo_zlib_classification/blob/0922c6b7b54946c1fea21c5fa3f96b6142d26e32/main.mojo#L89 line included in commit.

Then you just pip install -r requirements.txt, make all and mojo run main.mojo

System information

MacOS 14.3
Host Information
  ================

  Target Triple: aarch64-unknown-macosx
  CPU: apple-m1
  CPU Features: aes, complxnum, crc, dotprod, fp-armv8, fp16fml, fullfp16, jsconv, lse, neon, pauth, ras, rcpc, rdm, sha2, sha3

❯ mojo -v
mojo 24.1.0 (55ec12d6)
❯ modular -v
modular 0.5.1 (1b608e3d)
toiletsandpaper commented 8 months ago

So, error was caused by empty line at the end of the .csv file. IDK should I close this issue or leave it because of unhandled seg fault. My workaround is https://github.com/toiletsandpaper/mojo_zlib_classification/blob/2ef0a457a62eaaa2854ec36d7962b5067b182dc2/main.mojo#L73