Skip to content
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

Fixes issue of medium to large prompts causing crashing with no errors while using color mode. #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trevtravtrev
Copy link

…s while using color mode.

- This fixes a major application breaking untraceable error (Large prompts crashing with no error output antimatter15#122)
- Tested and working
@HCBlackFox
Copy link

Nice, this is works!

@michieal
Copy link

michieal commented Apr 4, 2023

if I may, what about doing something like this?

// Remove Magic Number, and make a #define:
#define INPUT_BUFFER_SIZE 16384

...

                    char buf[INPUT_BUFFER_SIZE] = {0};
                    int n_read;
                    if(params.use_color) printf(ANSI_BOLD ANSI_COLOR_GREEN);
	                std::string scan_line = std::string ("%") + std::to_string(INPUT_BUFFER_SIZE - 1) + "[^\n]%n%*c";

                    if (scanf(scan_line.c_str(), buf, &n_read) <= 0) {
                        // presumable empty line, consume the newline
                        if (scanf("%*c") <= 0) { /*ignore*/ }
                        n_read=0;
                    }

Mind you, I am really rusty on CPP... so, I am using Alpaca.cpp to get back into programming in c/cpp... That said, I think that this will work, and moves where one changes the input buf[] size to the top of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants