Path: utzoo!attcan!uunet!aplcen!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!apollo!caip.rutgers.edu!rutgers!cs.utexas.edu!sdd.hp.com!decwrl!lll-winken!sun-barr!ccut!kogwy!new1!roger From: roger@zuken.co.jp (Roger Meunier) Newsgroups: comp.windows.x.motif Subject: deep in the heap Message-ID: <4c0e7f10.20b6d@apollo.HP.COM> Date: 7 Aug 90 20:26:00 GMT Sender: root@apollo.HP.COM Organization: ZUKEN Inc. Yokohama, JAPAN Lines: 37 To: comp-windows-x-motif@rutgers.edu A few weeks ago, I got my hands on Conor P. Cahill's (uunet!virtech!cpcahil) malloc/string debugging library. I linked it with one of my Motif-based test applications to check for memory leaks, etc. in *my* code but ran into problems with the Motif library first. The memory-leak issue has been dealt with before, so I won't rehash it here. What concerns me is that the *bugs* I encountered could have been easily caught if someone testing Motif *before* letting it out into the real world would have done the simple tests which Mr. Cahill's library allows. For example: 1) Accessing free()'d memory. I hope this one is fixed in the next release. It occurred with my application and also with xmdialogs (from xmsamplers). Destroying any widget that contains a command, file selection box/dialog, or selection box/dialog and then returning to the event loop results in sombody trying to access the XmScrollBar widget *after* it has been deallocated. (Mr. Cahill's tool fills deallocated memory with a pattern which causes most applications to choke if they try to access it again. Motif choked at _XmAtomtoName+0x12a.) 2) Overrunning the end of an allocated buffer. I tried copying a string between XmText widgets using the secondary buffer. Motif apparently does a realloc() on some internal buffer, at which time it was discovered that someone had written 6 bytes into the buffer when only 5 were allocated. (On my machine, this didn't cause the program to crash, but I do remember a few months ago when my program *did* crash when I used this feature, but at that time I blamed it on my own coding. Who knows what else is lurking here...) Seeing as there are tools available which catch these sort of problems, I can only hope that they become widely used in the future. When trying to shake bugs out of my own code, it would be nice if I didn't have to hassle with someone elses... now who wants to argue with THAT? (I am using Motif 1.0 with X11R3 on HP9000 300-series under HP-UX 7.0.) -- Roger Meunier @ Zuken, Inc. Yokohama, Japan (roger@zuken.co.jp)