file_str_read crashes with '#' character

Posted By: Uhrwerk

file_str_read crashes with '#' character - 03/18/13 20:03

Hello jcl,

file_str_read produces a crash if the very first character in a file is '#'. Here are the steps necessary to reproduce the problem. First create a file test.txt with content like this:
Code:
#123456789

If you then execute the following snippet the engine will crash.
Code:
#include <acknex.h>

void main()
{
	var h = file_open_read("test.txt");
	if (h)
	{
		STRING* s = str_create("#128");
		file_str_read(h,s);
		printf("The content is:\n%s\nThe length is:\n%d",s->chars,(int)str_len(s));
		file_close(h);
	}
}

Best regards,
Uhrwerk
Posted By: jcl

Re: file_str_read crashes with '#' character - 03/19/13 07:42

Thanks! This will be fixed.
Posted By: Dico

Re: file_str_read crashes with '#' character - 03/19/13 12:09

Originally Posted By: Uhrwerk
Hello jcl,

file_str_read produces a crash if the very first character in a file is '#'. Here are the steps necessary to reproduce the problem. First create a file test.txt with content like this:
Code:
#123456789

If you then execute the following snippet the engine will crash.
Code:
#include <acknex.h>

void main()
{
	var h = file_open_read("test.txt");
	if (h)
	{
		STRING* s = str_create("#128");
		file_str_read(h,s);
		printf("The content is:\n%s\nThe length is:\n%d",s->chars,(int)str_len(s));
		file_close(h);
	}
}

Best regards,
Uhrwerk


the problem is not in file_str_read but in printf
Posted By: 3run

Re: file_str_read crashes with '#' character - 03/19/13 14:04

Originally Posted By: Dico
the problem is not in file_str_read but in printf
Use any other draw function f.e. debug_var or draw_text, and you'll see that bug is still there wink
Posted By: Dico

Re: file_str_read crashes with '#' character - 03/19/13 15:04

Originally Posted By: 3run
Originally Posted By: Dico
the problem is not in file_str_read but in printf
Use any other draw function f.e. debug_var or draw_text, and you'll see that bug is still there wink

but i test it with TEXT and it work nice without any problem .
but when i use printf the engine crash
Posted By: Dico

Re: file_str_read crashes with '#' character - 03/19/13 15:11

Originally Posted By: 3run
Originally Posted By: Dico
the problem is not in file_str_read but in printf
Use any other draw function f.e. debug_var or draw_text, and you'll see that bug is still there wink


try this

Code:
#include <acknex.h>

STRING* str_show = "";
TEXT* txt_d =
{
	string = str_show;
	pos_y = 200;
	flags = SHOW;
}

void main()
{
	var h = file_open_read("test.txt");
	if (h)
	{
		STRING* s = str_create("#128");
		file_str_read(h,s);
		//printf("The content is:\n%s\nThe length is:\n%d",s->chars,(int)str_len(s));
		str_cpy(str_show,s);
		
		file_close(h);
	}
}


there is no crash
Posted By: Dico

Re: file_str_read crashes with '#' character - 03/19/13 15:42

maybe there is another problem !!
Posted By: Uhrwerk

Re: file_str_read crashes with '#' character - 03/19/13 18:23

It is correct that your sample does not crash. But it does not set the string read to the correct contents from the file and takes ages to execute. So the bug is clearly related to file_str_read.

Please don't triple post.
Posted By: jcl

Re: file_str_read crashes with '#' character - 03/20/13 10:45

The problem was in file_str_read, but it might not cause a crash on any system.

The "#" was interpreted as in a string definition, so the program allocated a string of the size 123456789 bytes, but a string of this size was not expected, only a string of 11 bytes. Anyway it's fixed now.
Posted By: Uhrwerk

Re: file_str_read crashes with '#' character - 03/20/13 21:42

Well, on my machine the sample I posted above does crash. Maybe this is of any help to you:
Code:
Source
acknex.exe

Summary
Stopped working

Date
&#8206;3/&#8206;20/&#8206;2013 10:39 PM

Status
Report sent

Description
Faulting Application Path:	D:\Program Files (x86)\GStudio8\acknex.exe

Problem signature
Problem Event Name:	BEX
Application Name:	acknex.exe
Application Version:	0.0.0.0
Application Timestamp:	4c1231af
Fault Module Name:	StackHash_e98d
Fault Module Version:	0.0.0.0
Fault Module Timestamp:	00000000
Exception Offset:	20202020
Exception Code:	c0000005
Exception Data:	00000008
OS Version:	6.1.7601.2.1.0.256.48
Locale ID:	1033
Additional Information 1:	e98d
Additional Information 2:	e98dfca8bcf81bc1740adb135579ad53
Additional Information 3:	6eab
Additional Information 4:	6eabdd9e0dc94904be3b39a1c0583635

Extra information about the problem
Bucket ID:	2589014125

© 2024 lite-C Forums