delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/01/06/20:38:50

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
X-Authentication-Warning: hp2.xraylith.wisc.edu: khan owned process doing -bs
Date: Thu, 6 Jan 2000 19:41:15 -0600 (CST)
From: Mumit Khan <khan AT NanoTech DOT Wisc DOT EDU>
To: Jamie Guinan <guinan AT bluebutton DOT com>
cc: Cygwin Mailing List <cygwin AT sourceware DOT cygnus DOT com>
Subject: Re: Segfault when call kernel32 function
In-Reply-To: <Pine.LNX.4.10.10001061957490.2079-100000@gemini.home.net>
Message-ID: <Pine.HPP.3.96.1000106193708.1532B-100000@hp2.xraylith.wisc.edu>
MIME-Version: 1.0

On Thu, 6 Jan 2000, Jamie Guinan wrote:

> 
> I tried the same program with Mumit's gcc-2.95.2 distribution
> native on Win98.  Same problem, "BuildCommDCB()" just keeps
> crashing.  Both CRTDLL and MSVCRT versions. 
> 
> I think I can work around it with a combination of GetCommState()
> and SetCommState(), but I just find it weird that BuildCommDCB
> fails.  Oh, well.  :/
> 

I believe the bug is in Windows itself. Even though the prototype
says that you can supply the first parameter as LPCSTR (ie., 
`const char *'), Windows kernel will try to play with the string
it in place (possibly reformatting it, or something of that sort).

Solution:

1. Use -fwritable-strings option when compiling. Bad.

2. Use a static or allocated buffer and pass that instead.
   
   static char mode_str[] = "9600,...";
   BuildCommDCB (mode_str, &dcb);

Regards,
Mumit



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019