ggerganov / ggml

Tensor library for machine learning
MIT License
10.93k stars 1k forks source link

Call log callbacks before abort #930

Open thewh1teagle opened 1 month ago

thewh1teagle commented 1 month ago

I’m using ggml in Rust through bindings that call whisper.cpp, which in turn uses ggml. I noticed that whisper.cpp synchronizes ggml from this repository, so I thought it would be useful to report an issue here.

Currently, when an error occurs with ggml, it prints to stderr and then calls abort(). This approach makes it difficult to catch errors in production logs. The only workaround is to instruct users to run the program from a terminal in Windows and manually extract stderr output.

I have a mechanism in place that collects logs using a callback registered with whisper.cpp. However, the ggml abort function does not invoke this log callback before aborting.

Could you please modify the abort function to call the log callback before aborting? You can find the relevant code here. Additionally, abort() causes a complete crash of the program. It might be better to handle errors more gracefully, perhaps by implementing an error callback mechanism.