Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
how to debug

Posted by warem (warem), 30 March 2005
hi all,

if there is an error "Segmentation Fault", how to debug it?

thanks.

Posted by admin (Graham Ellis), 31 March 2005
"Segmentation fault"s really shouldn't occur in a pure Tcl program - they're normally caused by a memory leakage where one program is trying to access memory outside its area.

Are you embedding Tcl in your own C program?   If so, I would suggest you look there for the problem rather than in Tcl.   Are you loading C language libraries or procedures?   If so, have a look in there.

If your code is pure Tcl, then I would suggest two approaches:  (a) have a look through the known bugs / issues for the release that you're running and that may give you some clues - chances are that there's something in your code that's trigerring the error, but Tcl should not fail in this way.  (b) start running your code in sections and tie down the error to a smaller area of code for better investigation, and so that you can analyse and work around the problem.

Posted by warem (warem), 1 April 2005
my code is pure tcl.

my case is that:

for a entry widget, sometimes it is normal, i can input what i want. sometimes i can't input anything. it meant that when i pushed any key, no response, no letter came out in the entry widget.  sometimes, when i pushed any key, the "Segmentation fault" came out.

i am really confused.  

any suggestion?

Posted by admin (Graham Ellis), 1 April 2005
on 03/31/05 at 07:02:32, Graham Ellis wrote:
If your code is pure Tcl, then I would suggest two approaches:  (a) have a look through the known bugs / issues for the release that you're running and that may give you some clues - chances are that there's something in your code that's trigerring the error, but Tcl should not fail in this way.  (b) start running your code in sections and tie down the error to a smaller area of code for better investigation, and so that you can analyse and work around the problem.


Advice still stands.

If you can post up a short example (less than 20 lines) that shows the problem, and tell me what version of Tcl/Tk you're running and on what operating system, I'll have a look and see if I can see anything obvious.

Posted by warem (warem), 1 April 2005
tcl/tk: tcl-8.4.6
os   : suse linux

paste the below codes. it shoun run directly. the problem is discirbed above.
thank you.

another question, is it possible to build a "scrollbared frame" in tk? looking up
information from internet, "itk" can do it. how do it in tk?

#####################################################
#!/usr/bin/wish -f

# enable or disable button
proc lfEnableButtons {w} {
 global root_other_elements

 puts $w
 foreach child [winfo children $w] {
       puts ---$child
   if {$child == "$w.cb"} continue
     if {$::child_cb} {
       set root_other_elements 1
#        puts $child
#        foreach child1 [winfo children $child] {
#          puts $child1----
#          $child1 configure -state normal
#        }
#        if {$child == "$w.top"} {
#        puts "$child == $w.top"
#          $child.child selection from 0
#          $child.child selection to end
#        }
         $child configure -state normal
         $w.entry selection from 0
         $w.entry selection to end
     } else {
       set root_other_elements 0
       $child configure -state disabled
   }
 }
}

 set w ""

 labelframe $w.root -text "Root element"
 frame $w.root.other
 ## others for root
 labelframe $w.root.others
 checkbutton $w.root.others.cb -text "Other elements" -variable child_cb -command "lfEnableButtons $w.root.others" -padx 0
 $w.root.others configure -labelwidget $w.root.others.cb

 ### label
 label $w.root.others.label -text "Name:"
 $w.root.others.label configure -state disabled

 ### entry
 entry $w.root.others.entry -textvariable XML(child_name) -width 10
 $w.root.others.entry configure -state disabled
 $w.root.others.entry selection from 0
 $w.root.others.entry selection to end

 ### menu options
 tk_optionMenu $w.root.others.mutiple mutiple_option_child "exactly once" "one or more times" "zero or more times" "once or not at all"
 $w.root.others.mutiple configure -state disabled

 button $w.root.others.add -text "Add elements" -width 10 -command "add_element $w.root.others $w.misc"
 $w.root.others.add configure -state disabled

 #$w.root.others.mutiple $w.root.others.add
 pack $w.root.others.label $w.root.others.entry $w.root.others.mutiple $w.root.others.add -side left -padx 2m
 pack $w.root.others -side top -fill both -pady 1m
 pack $w.root -side top -fill both -expand 1 -pady 1m
######################################################

Posted by admin (Graham Ellis), 2 April 2005
That's a long example, but I cut and pasted it anyway and it ran fine for me a number of times until I pressed the "Add Elements" button when it errored. I'm running 8.4 but under Fedora core 2 for my testing; I have a variety of operating systems here, but not SUSE.

Since it didn't fail for me, what can I suggest to help you?

1. Tie the problem down by taking out parts of the program and seeing if the failure remains or goes away. You should aim to reduce your program to less that a third of its current length - less that 20 lines - in this process.  By removing code from your example, it is possible that you'll take a step that will remove the problem and thus lead you to clues and a solution.  If you reduce your program to purely the entry widget and still have the problem, then you'll have it in a very "tight" example where other people may be able to make more tuned, more helpful suggestions.

2., 3., 4.  Have you tried out 1. yet?  If not, go back and try it.

5. Have you been through the release notes for 8.4.7 and later via http://sourceforge.net/project/showfiles.php?group_id=10894 to see if there are any bugs / fixes reported that could be the issue that's effected you?

6. Have you tried minor changes to your code such as replacing the array element in your -textvariable with a simple "normal" variable, and also removing your "puts" commands back to the main control shell, and seeing if that effects the problem?

Posted by warem (warem), 2 April 2005
the coed pasted is stripped of my whole coeds.  it is just a small part of the whole. it seemed strange that the code worked in your computer (Fedora core 2). in fact, i couldn't input to the entry "Name:" so as far i posted this reply, i meant no response when i pushed any key.  is tcl/tk related with operating system??

it seemed that the problem is at the widget "labelframe".

at my original idea, "other element" is not necessary to exist. it means that it may or may not exist. it completely depends on users. so i added a checkbutton as the label of the labelframe. in the original state, all the widget in the "other element" is disbaled. if users check the checkbutton of the label of the labelframe, all the widgets in it are activated. when i input in the entry "Name:", then push the button "Add elements", it builds another widget in which has an entry. if i input in this entry, the Segmentation Fault came out.

if i don't use the checkbutton as the lableframe, or use a normal labelframe, or a frame, and make all the widgets activated at the beginning, it will work without any error.

so, the problem seemed to be the checkbutton of the label of the label frame. any idea for this?

another question?
####################################
how to build a scrollbared frame? when i continued to push the button "Add elemnets". the interface will be out of the range of the screen. so a scrollbar is necessary.
####################################

thanks.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho