slang-users mailing list

[2015 Date Index] [2015 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-users] slstdio.c / posixio.sl crash


Running 'tests/sltest.exe posixio.sl', invokes Dr Watson here on
Windows due to illegal argument to fclose() in slstdio.c:

	while (1)
	  {
	     if (0 == (t->flags & SL_PIPE))
	       {
		  if (EOF == (ret = fclose (fp)))  << !! 'fp' here is illegal
		    ret = -1;
	       }

I see the 't->flags == 0x2006'. I.e. SL_FDOPEN+SL_WRITE+SL_BINARY.
(SL_PIPE is 0x4000 so that if() seems correct).

But why the 'while(1)' loop? I'm not sure if the breakpoint gets
triggered on the 1st or 2nd round in that while-loop.

And AFAICS the logic around the 'SL_INUSE' flag-bit seems reversed.
In stdio_fclose():
  t->flags = SL_INUSE;

Shouldn't that be:
  t->flags &= ~SL_INUSE;

I don't get it. The code seems so obfuscated.

Here is the call-stack from the VC-2015 debugger:

 	ucrtbase.dll!__invoke_watson()	Unknown
 	ucrtbase.dll!__invalid_parameter()	Unknown
 	ucrtbase.dll!__invalid_parameter_noinfo()	Unknown
 	ucrtbase.dll!__close()	Unknown
 	ucrtbase.dll!__fclose_nolock()	Unknown
 	ucrtbase.dll!_fclose()	Unknown
	sltest.exe!close_file_type(SL_File_Table_Type * t) Line 429	
 	sltest.exe!destroy_file_type(unsigned int type, void * ptr) Line 1208	
 	sltest.exe!SLang_free_mmt(_pSLang_MMT_Type * ref) Line 1781	
 	sltest.exe!posix_close(_pSLFile_FD_Type * f) Line 379	
 	sltest.exe!execute_intrinsic_fun(SLang_Intrin_Fun_Type * objf) Line 3562	
 	sltest.exe!inner_interp(_pSLBlock_Type * addr_start) Line 5461	
 	sltest.exe!execute_slang_fun(_pSLang_Function_Type * fun, unsigned int linenum) Line 4586	
 	sltest.exe!inner_interp(_pSLBlock_Type * addr_start) Line 6055	
 	sltest.exe!lang_try_now() Line 7630	
 	sltest.exe!compile_token(_pSLang_Token_Type * t) Line 247	
 	sltest.exe!compile_token_list() Line 531	
 	sltest.exe!statement(_pSLang_Token_Type * ctok) Line 1260	
 	sltest.exe!statement_list(_pSLang_Token_Type * ctok) Line 1684	
 	sltest.exe!_pSLparse_start(SLang_Load_Type * llt) Line 1761	
 	sltest.exe!SLang_load_object(SLang_Load_Type * x) Line 1569	
 	sltest.exe!SLns_load_file(char * f, char * ns_name) Line 1824	
 	sltest.exe!SLang_load_file(char * f) Line 1768	
 	sltest.exe!main(int argc, char * * argv) Line 426	
 	[External Code]	

All this on Win 8.1 using MSVC v19; i.e. VStudio 2015.

--
--gv
_______________________________________________
For list information, visit <http://jedsoft.org/slang/mailinglists.html>.


[2015 date index] [2015 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]