slang-users mailing list

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

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


John E. Davis wrote:

Do the tests run to completion with the above change?  (You will also
have to  recompile sltest.exe).

Yes, fine. Except <crtdbg.h> must be included too.
Hence the patch is now:

--- a/slerr.c   2015-06-12 06:53:05
+++ b/slerr.c   2015-08-20 11:33:11
@@ -25,6 +25,10 @@
 #include "slang.h"
 #include "_slang.h"

+#ifdef __WIN32__
+#include <crtdbg.h>
+#endif
+
 void (*_pSLinterpreter_Error_Hook) (int) = NULL;

 void (*SLang_VMessage_Hook) (SLFUTURE_CONST char *, va_list) = NULL;
@@ -805,8 +809,29 @@
    return 0;
 }

+#ifdef __WIN32__
+static void invalid_parm_handler (const wchar_t* expression,
+                                 const wchar_t* function,
+                                 const wchar_t* file,
+                                 unsigned int line,
+                                 uintptr_t pReserved)
+{
+   (void) expression;
+   (void) function;
+   (void) file;
+   (void) line;
+   (void) pReserved;
+}
+#endif
+
 int _pSLerr_init (void)
 {
+#ifdef __WIN32__
+   (void) _set_invalid_parameter_handler (invalid_parm_handler);
+   /* Disable the message box for assertions. */
+   _CrtSetReportMode(_CRT_ASSERT, 0);
+#endif
+
    if (Default_Error_Queue == NULL)
      {
        Suspend_Error_Messages = 0;


Tested with MSVC and MingW (TDM-gcc). No crashes now.
But isn't this masking illegal parameters in programs
using SLang.lib statically too?


PS. the Yahoo SMTP server didn't like an address like "jed@xxxxxxxxxxx (John E. Davis)".
  So I had to reply to the list!

--
--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]