100% found this document useful (1 vote)
6 views

Python Debugging for AI, Machine Learning, and Cloud Computing: A Pattern-Oriented Approach 1st Edition Vostokov instant download

The document promotes the book 'Python Debugging for AI, Machine Learning, and Cloud Computing: A Pattern-Oriented Approach' by Dmitry Vostokov, which covers debugging techniques in Python for AI and machine learning applications. It emphasizes a pattern-oriented approach to diagnosing software issues and includes case studies and practical examples. Additionally, it provides links to download the book and explore related educational resources on ebookmass.com.

Uploaded by

vendanferme35
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
6 views

Python Debugging for AI, Machine Learning, and Cloud Computing: A Pattern-Oriented Approach 1st Edition Vostokov instant download

The document promotes the book 'Python Debugging for AI, Machine Learning, and Cloud Computing: A Pattern-Oriented Approach' by Dmitry Vostokov, which covers debugging techniques in Python for AI and machine learning applications. It emphasizes a pattern-oriented approach to diagnosing software issues and includes case studies and practical examples. Additionally, it provides links to download the book and explore related educational resources on ebookmass.com.

Uploaded by

vendanferme35
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

Download the full version and explore a variety of ebooks

or textbooks at https://ebookmass.com

Python Debugging for AI, Machine Learning, and


Cloud Computing: A Pattern-Oriented Approach 1st
Edition Vostokov

_____ Tap the link below to start your download _____

https://ebookmass.com/product/python-debugging-for-ai-
machine-learning-and-cloud-computing-a-pattern-oriented-
approach-1st-edition-vostokov/

Find ebooks or textbooks at ebookmass.com today!


Here are some recommended products for you. Click the link to
download, or explore more at ebookmass.com

Python Debugging for AI, Machine Learning, and Cloud


Computing: A Pattern-Oriented Approach 1st Edition Dmitry
Vostokov
https://ebookmass.com/product/python-debugging-for-ai-machine-
learning-and-cloud-computing-a-pattern-oriented-approach-1st-edition-
dmitry-vostokov/

Fundamentals of Trace and Log Analysis: A Pattern-Oriented


Approach to Monitoring, Diagnostics, and Debugging 1st
Edition Dmitry Vostokov
https://ebookmass.com/product/fundamentals-of-trace-and-log-analysis-
a-pattern-oriented-approach-to-monitoring-diagnostics-and-
debugging-1st-edition-dmitry-vostokov-2/

Fundamentals of Trace and Log Analysis A Pattern-Oriented


Approach to Monitoring, Diagnostics, and Debugging 1st
Edition Dmitry Vostokov
https://ebookmass.com/product/fundamentals-of-trace-and-log-analysis-
a-pattern-oriented-approach-to-monitoring-diagnostics-and-
debugging-1st-edition-dmitry-vostokov/

Artificial Intelligence and Machine Learning for EDGE


Computing 1st Edition Rajiv Pandey

https://ebookmass.com/product/artificial-intelligence-and-machine-
learning-for-edge-computing-1st-edition-rajiv-pandey/
Productionizing AI: How to Deliver AI B2B Solutions with
Cloud and Python 1st Edition Barry Walsh

https://ebookmass.com/product/productionizing-ai-how-to-deliver-
ai-b2b-solutions-with-cloud-and-python-1st-edition-barry-walsh/

Financial Machina: Machine Learning For Finance: The


Quintessential Compendium for Python Machine Learning For
2024 & Beyond Sampson
https://ebookmass.com/product/financial-machina-machine-learning-for-
finance-the-quintessential-compendium-for-python-machine-learning-
for-2024-beyond-sampson/

Productionizing AI: How to Deliver AI B2B Solutions with


Cloud and Python 1st Edition Barry Walsh

https://ebookmass.com/product/productionizing-ai-how-to-deliver-
ai-b2b-solutions-with-cloud-and-python-1st-edition-barry-walsh-2/

Foundations of ARM64 Linux Debugging, Disassembling, and


Reversing Dmitry Vostokov

https://ebookmass.com/product/foundations-of-arm64-linux-debugging-
disassembling-and-reversing-dmitry-vostokov/

Machine Learning Guide for Oil and Gas Using Python Hoss
Belyadi

https://ebookmass.com/product/machine-learning-guide-for-oil-and-gas-
using-python-hoss-belyadi/
Dmitry Vostokov

Python Debugging for AI, Machine


Learning, and Cloud Computing
A Pattern-Oriented Approach
Dmitry Vostokov
Dalkey, Dublin, Ireland

ISBN 978-1-4842-9744-5 e-ISBN 978-1-4842-9745-2


https://doi.org/10.1007/978-1-4842-9745-2

© Dmitry Vostokov 2024

Apress Standard

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

This Apress imprint is published by the registered company APress


Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
To Ekaterina, Alexandra, Kirill, and Maria
Introduction
Python is the dominant language used in AI and machine learning with
data and pipelines in cloud environments. Besides debugging Python
code in popular IDEs, notebooks, and command-line debuggers, this
book also includes coverage of native OS interfacing (Windows and
Linux) necessary to understand, diagnose, and debug complex software
issues.
The book begins with an introduction to pattern-oriented software
diagnostics and debugging processes that, before doing Python
debugging, diagnose problems in various software artifacts such as
memory dumps, traces, and logs. Next, it teaches various debugging
patterns using Python case studies that model abnormal software
behavior. Further, it covers Python debugging specifics in cloud native
and machine learning environments. It concludes with how recent
advances in AI/ML can help in Python debugging. The book also goes
deep for case studies when there are environmental problems, crashes,
hangs, resource spikes, leaks, and performance degradation. It includes
tracing and logging besides memory dumps and their analysis using
native WinDbg and GDB debuggers.
This book is for those who wish to understand how Python
debugging is and can be used to develop robust and reliable AI,
machine learning, and cloud computing software. It uses a novel
pattern-oriented approach to diagnosing and debugging abnormal
software structure and behavior. Software developers, AI/ML
engineers, researchers, data engineers, MLOps, DevOps, and anyone
who uses Python will benefit from this book.
Source Code: All source code used in this book can be downloaded
from github.com/Apress/Python-Debugging-for-AI-
Machine-Learning-and-Cloud-Computing.
Any source code or other supplementary material referenced by the
author in this book is available to readers on GitHub. For more detailed
information, please visit https://www.apress.com/gp/services/source-
code.
Table of Contents
Chapter 1:​Fundamental Vocabulary
Process
Thread
Stack Trace (Backtrace, Traceback)
Symbol Files
Module
Memory Dump
Crash
Hang
Summary
Chapter 2:​Pattern-Oriented Debugging
The History of the Idea
Patterns and Analysis Patterns
Development Process
Development Patterns
Debugging Process and Patterns
Elementary Diagnostics Patterns
Debugging Analysis Patterns
Debugging Architecture Patterns
Debugging Design Patterns
Debugging Implementation Patterns
Debugging Usage Patterns
Debugging Presentation Patterns
Summary
Chapter 3:​Elementary Diagnostics Patterns
Functional Patterns
Use-Case Deviation
Non-Functional Patterns
Crash
Hang
Counter Value
Error Message
Summary
Chapter 4:​Debugging Analysis Patterns
Paratext
State Dump
Counter Value
Stack Trace Patterns
Stack Trace
Runtime Thread
Managed Stack Trace
Source Stack Trace
Stack Trace Collection
Stack Trace Set
Exception Patterns
Managed Code Exception
Nested Exception
Exception Stack Trace
Software Exception
Module Patterns
Module Collection
Not My Version
Exception Module
Origin Module
Thread Patterns
Spiking Thread
Active Thread
Blocked Thread
Blocking Module
Synchronization Patterns
Wait Chain
Deadlock
Livelock
Memory Consumption Patterns
Memory Leak
Handle Leak
Case Study
Summary
Chapter 5:​Debugging Implementation Patterns
Overview of Patterns
Break-Ins
Code Breakpoint
Code Trace
Scope
Variable Value
Type Structure
Breakpoint Action
Usage Trace
Case Study
Elementary Diagnostics Patterns
Debugging Analysis Patterns
Debugging Implementation Patterns
Summary
Chapter 6:​IDE Debugging in the Cloud
Visual Studio Code
WSL Setup
Cloud SSH Setup
Case Study
Summary
Chapter 7:​Debugging Presentation Patterns
Python Debugging Engines
Case Study
Suggested Presentation Patterns
Summary
Chapter 8:​Debugging Architecture Patterns
The Where?​Category
In Papyro
In Vivo
In Vitro
In Silico
In Situ
Ex Situ
The When?​Category
Live
JIT
Postmortem
The What?​Category
Code
Data
Interaction
The How?​Category
Software Narrative
Software State
Summary
Chapter 9:​Debugging Design Patterns
CI Build Case Study
Elementary Diagnostics
Analysis
Architecture
Design
Implementation
Data Processing Case Study
Elementary Diagnostics
Analysis
Architecture
Design
Implementation
Summary
Chapter 10:​Debugging Usage Patterns
Exact Sequence
Scripting
Debugger Extension
Abstract Command
Space Translation
Lifting
Gestures
Summary
Chapter 11:​Case Study:​Resource Leaks
Elementary Diagnostics
Debugging Analysis
Debugging Architecture
Debugging Implementation
Summary
Chapter 12:​Case Study:​Deadlock
Elementary Diagnostics
Debugging Analysis
Debugging Architecture
Exceptions and Deadlocks
Summary
Chapter 13:​Challenges of Python Debugging in Cloud Computing
Complex Distributed Systems
Granularity of Services
Communication Channels Overhead
Inter-Service Dependencies
Layers of Abstraction
Opaque Managed Services
Serverless and Function as a Service
Container Orchestration Platforms
Continuous Integration/​Continuous Deployment
Pipeline Failures
Rollbacks and Versioning
Immutable Infrastructure
Diversity of Cloud Service Models
Infrastructure as a Service
Platform as a Service
Software as a Service
Evolving Cloud Platforms
Adapting to Changes
Staying Updated
Environment Parity
Library and Dependency Disparities
Configuration Differences
Underlying Infrastructure Differences
Service Variabilities
Limited Visibility
Transient Resources
Log Management
Monitoring and Alerting
Latency and Network Issues
Network Instabilities
Service-to-Service Communication
Resource Leaks and Performance
Resource Starvation
Concurrency Issues
Race Conditions
Deadlocks
Security and Confidentiality
Debugger Access Control Restrictions
Sensitive Data Exposure
Limited Access
Cost Implications
Extended Sessions
Resource Provisioning and Deprovisioning
Data Transfer and Storage Fees
State Management
Stateful Services
Data Volume
Limited Tooling Compatibility
Versioning Issues
Deprecations and Changes
SDK and Library Updates
Real-time Debugging and User Experience
External Service Dependencies
Dependency Failures
Rate Limiting and Quotas
Asynchronous Operations
Flow Tracking
Error Propagation
Scaling and Load Challenges
Load-Based Issues
Resource Contention
Multi-Tenancy Issues
Resource Contention
Data Security
Reliability and Redundancy Issues
Service Failures
Data Durability
Summary
Chapter 14:​Challenges of Python Debugging in AI and Machine
Learning
The Nature of Defects in AI/​ML
Complexity and Abstraction Layers
Non-Determinism and Reproducibility
Large Datasets
High-Dimensional Data
Long Training Times
Real-Time Operation
Model Interpretability​
Hardware Challenges
Version Compatibility and Dependency Hell
Data Defects
Inconsistent and Noisy Data
Data Leakage
Imbalanced Data
Data Quality
Feature Engineering Flaws
Algorithmic and Model-Specific Defects
Gradients, Backpropagation, and Automatic Differentiation
Hyperparameter Tuning
Overfitting and Underfitting
Algorithm Choice
Deep Learning Defects
Activation and Loss Choices
Learning Rate
Implementation Defects
Tensor Shapes
Hardware Limitations and Memory
Custom Code
Performance Bottlenecks
Testing and Validation
Unit Testing
Model Validation
Cross-Validation
Metrics Monitoring
Visualization for Debugging
TensorBoard
Matplotlib and Seaborn
Model Interpretability​
Logging and Monitoring
Checkpoints
Logging
Alerts
Error Tracking Platforms
Collaborative Debugging
Forums and Communities
Peer Review
Documentation, Continuous Learning, and Updates
Maintaining Documentation
Library Updates
Continuous Learning
Case Study
Summary
Chapter 15:​What AI and Machine Learning Can Do for Python
Debugging
Automated Error Detection
Intelligent Code Fix Suggestions
Interaction Through Natural Language Queries
Visual Debugging Insights
Diagnostics and Anomaly Detection
Augmenting Code Reviews
Historical Information Analysis and Prognostics
Adaptive Learning and Personalized Debugging Experience
Test Suite Integration and Optimization
Enhanced Documentation and Resource Suggestions
Problem Modeling
Generative Debugging Strategy
Help with In Papyro Debugging
Summary
Chapter 16:​The List of Debugging Patterns
Elementary Diagnostics Patterns
Debugging Analysis Patterns
Debugging Architecture Patterns
Debugging Design Patterns
Debugging Implementation Patterns
Debugging Usage Patterns
Debugging Presentation Patterns
Index
About the Author
Dmitry Vostokov
is an internationally recognized expert,
speaker, educator, scientist, inventor, and
author. He founded the pattern-oriented
software diagnostics, forensics, and
prognostics discipline (Systematic
Software Diagnostics) and Software
Diagnostics Institute (DA+TA:
DumpAnalysis.org + TraceAnalysis.org).
Vostokov has also authored multiple
books on software diagnostics, anomaly
detection and analysis, software, and
memory forensics, root cause analysis
and problem-solving, memory dump
analysis, debugging, software trace and log analysis, reverse
engineering, and malware analysis. He has over thirty years of
experience in software architecture, design, development, and
maintenance in various industries, including leadership, technical, and
people management roles. In his spare time, he presents multiple topics
on Debugging.TV and explores software narratology and its further
development as narratology of things and diagnostics of things (DoT),
software pathology, and quantum software diagnostics. His current
interest areas are theoretical software diagnostics and its mathematical
and computer science foundations, application of formal logic, artificial
intelligence, machine learning, and data mining to diagnostics and
anomaly detection, software diagnostics engineering and diagnostics-
driven development, diagnostics workflow, and interaction. Recent
interest areas also include cloud native computing, security,
automation, functional programming, applications of category theory to
software development and big data, and artificial intelligence
diagnostics.
About the Technical Reviewer
Krishnendu Dasgupta
is currently the Head of Machine
Learning at Mondosano GmbH, leading
data science initiatives focused on
clinical trial recommendations and
advanced patient health profiling
through disease and drug data. Prior to
this role, he co-founded DOCONVID AI, a
startup that leveraged applied AI and
medical imaging to detect lung
abnormalities and neurological
disorders.
With a strong background in
computer science engineering,
Krishnendu has more than a decade of experience in developing
solutions and platforms using applied machine learning. His
professional trajectory includes key positions at prestigious
organizations such as NTT DATA, PwC, and Thoucentric.
Krishnendu’s primary research interests include applied AI for
graph machine learning, medical imaging, and decentralized privacy-
preserving machine learning in healthcare. He also had the opportunity
to participate in the esteemed Entrepreneurship and Innovation
Bootcamp at the Massachusetts Institute of Technology, cohort of 2018
batch.
Beyond his professional endeavors, Krishnendu actively dedicates
his time to research, collaborating with various research NGOs and
universities worldwide. His focus is on applied AI and ML.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
D. Vostokov, Python Debugging for AI, Machine Learning, and Cloud Computing
https://doi.org/10.1007/978-1-4842-9745-2_1

1. Fundamental Vocabulary
Dmitry Vostokov1

(1) Dalkey, Dublin, Ireland

Debugging complex software issues in machine learning and cloud computing


environments requires not only the knowledge of the Python language and its interpreter
(or compiler), plus standard and external libraries, but also necessary and relevant
execution environment and operating system internals. In this chapter, you will review
some necessary fundamentals from software diagnostics and debugging languages to
have the same base level of understanding for the following chapters. In this book, I
assume that you are familiar with the Python language and its runtime environment.

Process
A Python script is interpreted by compiling it into bytecode and then executing it, or it
can even be precompiled into an application program. In both cases, this interpreter file
or the compiled application is an executable program (in Windows, it may have a .exe
extension) that references some operating system libraries (.dll in Windows and .so in
Linux). This application can be loaded into computer memory several times; each time, a
separate process is created with its own resources and unique process ID (PID, also
TGID), as shown in Figure 1-1. The process may also have a parent process that created it,
with a parent process ID (PPID).
Figure 1-1 Two python3 processes with two different PIDs
To illustrate, I executed the code in Listing 1-1 on both Windows and Linux twice.

import time

def main():
foo()

def foo():
bar()

def bar():
while True:
time.sleep(1)

if __name__ == "__main__":
main()
Listing 1-1 A Simple Script to Model Running Python Code

Figure 1-2 shows two processes on Windows.


Figure 1-2 Two running python3.11.exe processes on Windows
On Linux, you can also see two processes when you execute the same script in two
separate terminals:

~/Chapter1$ which python3


/usr/bin/python3

~/Chapter1$ ps -a
PID TTY TIME CMD
17 pts/0 00:00:00 mc
60 pts/2 00:00:00 python3
61 pts/1 00:00:00 python3
80 pts/3 00:00:00 ps

Note The operating system controls hardware and processes/threads. From a high
level, it is just a collection of processes with the operating system kernel as a process
too.

Thread
From an operating system perspective, a process is just a memory container for a Python
interpreter, its code, and data. But the interpreter code needs to be executed, for example,
to interpret the Python bytecode. This unit of execution is called a thread. A process may
have several such units of execution (several threads, the so-called multithreaded
application). Each thread has its own unique thread ID (TID, also LWP or SPID), as shown
in Figure 1-3. For example, one thread may process user interface events and others may
do complex calculations in response to UI requests, thus making the UI responsive. On
Windows, thread IDs are usually different from process IDs, but in Linux, the thread ID of
the main thread is the same as the process ID for a single-threaded process.

Figure 1-3 Two python3 processes with different numbers of threads


To model multithreading, I executed the code in Listing 1-2 on both Windows and
Linux.

import time
import threading

def thread_func():
foo()

def main():
t1 = threading.Thread(target=thread_func)
t1.start()
t2 = threading.Thread(target=thread_func)
t2.start()
t1.join()
t2.join()
def foo():
bar()

def bar():
while True:
time.sleep(1)

if __name__ == "__main__":
main()
Listing 1-2 A Simple Script to Model Multiple Threads
Figure 1-4 shows that in Windows, you can see 11 threads at the beginning (this
number later changes to 7 and then to 5). You see that the number of threads may be
greater than expected.

Figure 1-4 The number of threads in the running python3.11.exe process on Windows

In Linux, you can see the expected number of threads – 3:

~/Chapter1$ ps -aT
PID SPID TTY TIME CMD
17 17 pts/0 00:00:00 mc
45 45 pts/2 00:00:00 python3
45 46 pts/2 00:00:00 python3
45 47 pts/2 00:00:00 python3
54 54 pts/1 00:00:00 ps
Stack Trace (Backtrace, Traceback)
I should distinguish Python source code tracebacks (which we call managed stack traces)
and unmanaged (native) ones from the Python compiler and interpreter that compiles to
and executes Python byte code. You will see this distinction in some chapters for several
case studies and how to get both traces. But, for now, I will just show the difference.
Listing 1-3 shows managed stack trace. Listing 1-4 shows the corresponding unmanaged
Linux stack trace with debugging symbols (the most recent call first). Listing 1-5 shows
the corresponding unmanaged Windows stack trace without debugging symbols (the
most recent call first).

Traceback (most recent call last):


File "process.py", line 14, in <module>
main()
File "process.py", line 4, in main
foo()
File "process.py", line 7, in foo
bar()
File "process.py", line 11, in bar
time.sleep(1)
Listing 1-3 Managed Stack Trace from the Execution of the Python Script from Listing 1-1

#0 0x00007f6bc84e6b97 in __GI___select (nfds=0, readfds=0x0,


writefds=0x0, exceptfds=0x0, timeout=0x7ffc60288fe0)
at ../sysdeps/unix/sysv/linux/select.c:41
#1 0x00000000004e8965 in pysleep (secs=<optimized out>) at
../Modules/timemodule.c:1829
#2 time_sleep (self=<optimized out>, obj=<optimized out>,
self=<optimized out>, obj=<optimized out>)
at ../Modules/timemodule.c:371
#3 0x00000000005d8711 in _PyMethodDef_RawFastCallKeywords
(method=0x82dbe0 <time_methods+288>,
self=<module at remote 0x7f6bc800dc78>,
args=0x7f6bc80c4550, nargs=<optimized out>, kwnames=<optimized
out>)
at ../Objects/call.c:644
#4 0x000000000054b330 in _PyCFunction_FastCallKeywords
(kwnames=<optimized out>, nargs=<optimized out>,
args=0x7f6bc80c4550, func=<built-in method sleep of module
object at remote 0x7f6bc800dc78>)
at ../Objects/call.c:730
#5 call_function (pp_stack=0x7ffc60289150, oparg=<optimized
out>, kwnames=<optimized out>) at ../Python/ceval.c:4568
#6 0x00000000005524cd in _PyEval_EvalFrameDefault (f=
<optimized out>, throwflag=<optimized out>)
at ../Python/ceval.c:3093
#7 0x00000000005d91fc in PyEval_EvalFrameEx (throwflag=0,
f=Frame 0x7f6bc80c43d8, for file process.py, line 11, in
bar ()) at ../Python/ceval.c:547
#8 function_code_fastcall (globals=<optimized out>, nargs=
<optimized out>, args=<optimized out>, co=<optimized out>)
at ../Objects/call.c:283
#9 _PyFunction_FastCallKeywords (func=<optimized out>, stack=
<optimized out>, nargs=<optimized out>,
kwnames=<optimized out>) at ../Objects/call.c:408
#10 0x000000000054e5ac in call_function (kwnames=0x0, oparg=
<optimized out>, pp_stack=<synthetic pointer>)
at ../Python/ceval.c:4616
#11 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=
<optimized out>) at ../Python/ceval.c:3124
#12 0x00000000005d91fc in PyEval_EvalFrameEx (throwflag=0,
f=Frame 0x7f6bc80105e8, for file process.py, line 7, in foo
()) at ../Python/ceval.c:547
#13 function_code_fastcall (globals=<optimized out>, nargs=
<optimized out>, args=<optimized out>, co=<optimized out>)
at ../Objects/call.c:283
#14 _PyFunction_FastCallKeywords (func=<optimized out>, stack=
<optimized out>, nargs=<optimized out>,
kwnames=<optimized out>) at ../Objects/call.c:408
--Type <RET> for more, q to quit, c to continue without paging-
-
#15 0x000000000054e5ac in call_function (kwnames=0x0, oparg=
<optimized out>, pp_stack=<synthetic pointer>)
at ../Python/ceval.c:4616
#16 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=
<optimized out>) at ../Python/ceval.c:3124
#17 0x00000000005d91fc in PyEval_EvalFrameEx (throwflag=0,
f=Frame 0x205ade8, for file process.py, line 4, in main ())
at ../Python/ceval.c:547
#18 function_code_fastcall (globals=<optimized out>, nargs=
<optimized out>, args=<optimized out>, co=<optimized out>)
at ../Objects/call.c:283
#19 _PyFunction_FastCallKeywords (func=<optimized out>, stack=
<optimized out>, nargs=<optimized out>,
kwnames=<optimized out>) at ../Objects/call.c:408
#20 0x000000000054e5ac in call_function (kwnames=0x0, oparg=
<optimized out>, pp_stack=<synthetic pointer>)
at ../Python/ceval.c:4616
#21 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=
<optimized out>) at ../Python/ceval.c:3124
#22 0x000000000054bcc2 in PyEval_EvalFrameEx (throwflag=0,
f=Frame 0x7f6bc80ab9f8, for file process.py, line 14, in
<module> ()) at ../Python/ceval.c:547
#23 _PyEval_EvalCodeWithName (_co=<optimized out>, globals=
<optimized out>, locals=<optimized out>,
args=<optimized out>, argcount=<optimized out>,
kwnames=0x0, kwargs=0x0, kwcount=<optimized out>, kwstep=2,
defs=0x0, defcount=0, kwdefs=0x0, closure=0x0, name=0x0,
qualname=0x0) at ../Python/ceval.c:3930
#24 0x000000000054e0a3 in PyEval_EvalCodeEx (closure=0x0,
kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0,
argcount=0, args=0x0, locals=<optimized out>, globals=
<optimized out>, _co=<optimized out>)
at ../Python/ceval.c:3959
#25 PyEval_EvalCode (co=<optimized out>, globals=<optimized
out>, locals=<optimized out>) at ../Python/ceval.c:524
#26 0x0000000000630ce2 in run_mod (mod=<optimized out>,
filename=<optimized out>,
globals={'__name__': '__main__', '__doc__': None,
'__package__': None, '__loader__':
<SourceFileLoader(name='__main__', path='process.py') at remote
0x7f6bc803dfd0>, '__spec__': None, '__annotations__': {},
'__builtins__': <module at remote 0x7f6bc8102c28>, '__file__':
'process.py', '__cached__': None, 'time': <module at remote
0x7f6bc800dc78>, 'main': <function at remote 0x7f6bc80791e0>,
'foo': <function at remote 0x7f6bc7f69c80>, 'bar': <function at
remote 0x7f6bc7f69d08>},
locals={'__name__': '__main__', '__doc__': None,
'__package__': None, '__loader__':
<SourceFileLoader(name='__main__', path='process.py') at remote
0x7f6bc803dfd0>, '__spec__': None, '__annotations__': {},
'__builtins__': <module at rem--Type <RET> for more, q to quit,
c to continue without paging--
ote 0x7f6bc8102c28>, '__file__': 'process.py', '__cached__':
None, 'time': <module at remote 0x7f6bc800dc78>, 'main':
<function at remote 0x7f6bc80791e0>, 'foo': <function at remote
0x7f6bc7f69c80>, 'bar': <function at remote 0x7f6bc7f69d08>},
flags=<optimized out>, arena=<optimized out>) at
../Python/pythonrun.c:1035
#27 0x0000000000630d97 in PyRun_FileExFlags (fp=0x2062390,
filename_str=<optimized out>, start=<optimized out>,
globals={'__name__': '__main__', '__doc__': None,
'__package__': None, '__loader__':
<SourceFileLoader(name='__main__', path='process.py') at remote
0x7f6bc803dfd0>, '__spec__': None, '__annotations__': {},
'__builtins__': <module at remote 0x7f6bc8102c28>, '__file__':
'process.py', '__cached__': None, 'time': <module at remote
0x7f6bc800dc78>, 'main': <function at remote 0x7f6bc80791e0>,
'foo': <function at remote 0x7f6bc7f69c80>, 'bar': <function at
remote 0x7f6bc7f69d08>},
locals={'__name__': '__main__', '__doc__': None,
'__package__': None, '__loader__':
<SourceFileLoader(name='__main__', path='process.py') at remote
0x7f6bc803dfd0>, '__spec__': None, '__annotations__': {},
'__builtins__': <module at remote 0x7f6bc8102c28>, '__file__':
'process.py', '__cached__': None, 'time': <module at remote
0x7f6bc800dc78>, 'main': <function at remote 0x7f6bc80791e0>,
'foo': <function at remote 0x7f6bc7f69c80>, 'bar': <function at
remote 0x7f6bc7f69d08>}, closeit=1, flags=0x7ffc6028989c) at
../Python/pythonrun.c:988
#28 0x00000000006319ff in PyRun_SimpleFileExFlags
(fp=0x2062390, filename=<optimized out>, closeit=1,
flags=0x7ffc6028989c) at ../Python/pythonrun.c:429
#29 0x000000000065432e in pymain_run_file (p_cf=0x7ffc6028989c,
filename=<optimized out>, fp=0x2062390)
at ../Modules/main.c:427
#30 pymain_run_filename (cf=0x7ffc6028989c,
pymain=0x7ffc60289970) at ../Modules/main.c:1627
#31 pymain_run_python (pymain=0x7ffc60289970) at
../Modules/main.c:2877
#32 pymain_main (pymain=<optimized out>, pymain=<optimized
out>) at ../Modules/main.c:3038
#33 0x000000000065468e in _Py_UnixMain (argc=<optimized out>,
argv=<optimized out>) at ../Modules/main.c:3073
#34 0x00007f6bc841a09b in __libc_start_main (main=0x4bc560
<main>, argc=2, argv=0x7ffc60289ab8, init=<optimized out>,
fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7ffc60289aa8) at ../csu/libc-start.c:308
#35 0x00000000005e0e8a in _start () at ../Modules/main.c:797
Listing 1-4 Unmanaged Linux Backtrace from the Execution of the Python Script from Listing 1-1 with
Debugging Symbols

00 00000090`7e1ef0a8
00007ff9`8c44fcf9 ntdll!NtWaitForMultipleObjects+0x14
01 00000090`7e1ef0b0
00007ff9`8c44fbfe KERNELBASE!WaitForMultipleObjectsEx+0xe9
02 00000090`7e1ef390
00007ff8`ef943986 KERNELBASE!WaitForMultipleObjects+0xe
03 00000090`7e1ef3d0
00007ff8`ef94383d python311!PyTraceBack_Print_Indented+0x35a
04 00000090`7e1ef430
00007ff8`ef81a6b2 python311!PyTraceBack_Print_Indented+0x211
05 00000090`7e1ef460
00007ff8`ef82fa77 python311!PyEval_EvalFrameDefault+0x8f2
06 00000090`7e1ef670
00007ff8`ef82f137 python311!PyMapping_Check+0x1eb
07 00000090`7e1ef6b0
00007ff8`ef82d80a python311!PyEval_EvalCode+0x97
08 00000090`7e1ef730
00007ff8`ef82d786 python311!PyMapping_Items+0x11e
09 00000090`7e1ef760
00007ff8`ef97a17e python311!PyMapping_Items+0x9a
0a 00000090`7e1ef7a0
00007ff8`ef7e33a5 python311!PyThread_tss_is_created+0x53ce
0b 00000090`7e1ef810
00007ff8`ef8da620 python311!PyRun_SimpleFileObject+0x11d
0c 00000090`7e1ef880
00007ff8`ef8daaef python311!PyRun_AnyFileObject+0x54
0d 00000090`7e1ef8b0
00007ff8`ef8dab5f python311!Py_MakePendingCalls+0x38f
0e 00000090`7e1ef980
00007ff8`ef8db964 python311!Py_MakePendingCalls+0x3ff
0f 00000090`7e1ef9b0
00007ff8`ef8db7f5 python311!Py_RunMain+0x184
10 00000090`7e1efa20
00007ff8`ef8260d9 python311!Py_RunMain+0x15
11 00000090`7e1efa50
00007ff6`aefe1230 python311!Py_Main+0x25
12 00000090`7e1efaa0 00007ff9`8e1c26ad python+0x1230
13 00000090`7e1efae0
00007ff9`8ef6a9f8 KERNEL32!BaseThreadInitThunk+0x1d
14 00000090`7e1efb10
00000000`00000000 ntdll!RtlUserThreadStart+0x28
Listing 1-5 Unmanaged Windows Stack Trace from the Execution of the Python Script from Listing 1-1
Without Debugging Symbols

Note Each thread has its own stack trace (backtrace).

Symbol Files
Symbol files allow a debugger to map memory addresses to symbolic information such as
function and variable names. For example, if you download and apply symbol files to the
Windows example above, you get a much better and more accurate stack trace, as shown
in Listing 1-6.

00 00000090`7e1ef0a8
00007ff9`8c44fcf9 ntdll!NtWaitForMultipleObjects+0x14
01 00000090`7e1ef0b0
00007ff9`8c44fbfe KERNELBASE!WaitForMultipleObjectsEx+0xe9
02 00000090`7e1ef390
00007ff8`ef943986 KERNELBASE!WaitForMultipleObjects+0xe
03 00000090`7e1ef3d0
00007ff8`ef94383d python311!pysleep+0x11a
04 00000090`7e1ef430
00007ff8`ef81a6b2 python311!time_sleep+0x2d
05 00000090`7e1ef460
00007ff8`ef82fa77 python311!_PyEval_EvalFrameDefault+0x8f2
06 (Inline Function) --------`-------
- python311!_PyEval_EvalFrame+0x1e
07 00000090`7e1ef670
00007ff8`ef82f137 python311!_PyEval_Vector+0x77
08 00000090`7e1ef6b0
00007ff8`ef82d80a python311!PyEval_EvalCode+0x97
09 00000090`7e1ef730
00007ff8`ef82d786 python311!run_eval_code_obj+0x52
0a 00000090`7e1ef760
00007ff8`ef97a17e python311!run_mod+0x72
0b 00000090`7e1ef7a0
00007ff8`ef7e33a5 python311!pyrun_file+0x196b66
0c 00000090`7e1ef810
00007ff8`ef8da620 python311!_PyRun_SimpleFileObject+0x11d
0d 00000090`7e1ef880
00007ff8`ef8daaef python311!_PyRun_AnyFileObject+0x54
0e 00000090`7e1ef8b0
00007ff8`ef8dab5f python311!pymain_run_file_obj+0x10b
0f 00000090`7e1ef980
00007ff8`ef8db964 python311!pymain_run_file+0x63
10 00000090`7e1ef9b0
00007ff8`ef8db7f5 python311!pymain_run_python+0x140
11 00000090`7e1efa20
00007ff8`ef8260d9 python311!Py_RunMain+0x15
12 00000090`7e1efa50
00007ff6`aefe1230 python311!Py_Main+0x25
13 (Inline Function) --------`-------
- python!invoke_main+0x22
14 00000090`7e1efaa0
00007ff9`8e1c26ad python!__scrt_common_main_seh+0x10c
15 00000090`7e1efae0
00007ff9`8ef6a9f8 KERNEL32!BaseThreadInitThunk+0x1d
16 00000090`7e1efb10
00000000`00000000 ntdll!RtlUserThreadStart+0x28
Listing 1-6 Unmanaged Windows Stack Trace from the Execution of the Python Script from Listing 1-1
with Debugging Symbols
Module
Like the distinction between managed and unmanaged stack traces, there is a difference
between Python modules (which may correspond to files in traceback) and native
modules such as DLLs in Windows and .so files in Linux, which are loaded into memory
when you execute the Python compiler/interpreter. For example, the following shared
libraries are loaded in Linux for the simple multithreaded example from Listing 1-2:

~/Chapter1$ pmap 60
60: python3 process.py
0000000000400000 132K r---- python3.7
0000000000421000 2256K r-x-- python3.7
0000000000655000 1712K r---- python3.7
0000000000801000 4K r---- python3.7
0000000000802000 664K rw--- python3.7
00000000008a8000 140K rw--- [ anon ]
0000000001fff000 660K rw--- [ anon ]
00007f6bc7f69000 1684K rw--- [ anon ]
00007f6bc810e000 2964K r---- locale-archive
00007f6bc83f3000 12K rw--- [ anon ]
00007f6bc83f6000 136K r---- libc-2.28.so
00007f6bc8418000 1308K r-x-- libc-2.28.so
00007f6bc855f000 304K r---- libc-2.28.so
00007f6bc85ab000 4K ----- libc-2.28.so
00007f6bc85ac000 16K r---- libc-2.28.so
00007f6bc85b0000 8K rw--- libc-2.28.so
00007f6bc85b2000 16K rw--- [ anon ]
00007f6bc85b6000 52K r---- libm-2.28.so
00007f6bc85c3000 636K r-x-- libm-2.28.so
00007f6bc8662000 852K r---- libm-2.28.so
00007f6bc8737000 4K r---- libm-2.28.so
00007f6bc8738000 4K rw--- libm-2.28.so
00007f6bc8739000 8K rw--- [ anon ]
00007f6bc873b000 12K r---- libz.so.1.2.11
00007f6bc873e000 72K r-x-- libz.so.1.2.11
00007f6bc8750000 24K r---- libz.so.1.2.11
00007f6bc8756000 4K ----- libz.so.1.2.11
00007f6bc8757000 4K r---- libz.so.1.2.11
00007f6bc8758000 4K rw--- libz.so.1.2.11
00007f6bc8759000 16K r---- libexpat.so.1.6.8
00007f6bc875d000 132K r-x-- libexpat.so.1.6.8
00007f6bc877e000 80K r---- libexpat.so.1.6.8
00007f6bc8792000 4K ----- libexpat.so.1.6.8
00007f6bc8793000 8K r---- libexpat.so.1.6.8
00007f6bc8795000 4K rw--- libexpat.so.1.6.8
00007f6bc8796000 4K r---- libutil-2.28.so
00007f6bc8797000 4K r-x-- libutil-2.28.so
00007f6bc8798000 4K r---- libutil-2.28.so
00007f6bc8799000 4K r---- libutil-2.28.so
00007f6bc879a000 4K rw--- libutil-2.28.so
00007f6bc879b000 4K r---- libdl-2.28.so
00007f6bc879c000 4K r-x-- libdl-2.28.so
00007f6bc879d000 4K r---- libdl-2.28.so
00007f6bc879e000 4K r---- libdl-2.28.so
00007f6bc879f000 4K rw--- libdl-2.28.so
00007f6bc87a0000 24K r---- libpthread-2.28.so
00007f6bc87a6000 60K r-x-- libpthread-2.28.so
00007f6bc87b5000 24K r---- libpthread-2.28.so
00007f6bc87bb000 4K r---- libpthread-2.28.so
00007f6bc87bc000 4K rw--- libpthread-2.28.so
00007f6bc87bd000 16K rw--- [ anon ]
00007f6bc87c1000 4K r---- libcrypt-2.28.so
00007f6bc87c2000 24K r-x-- libcrypt-2.28.so
00007f6bc87c8000 8K r---- libcrypt-2.28.so
00007f6bc87ca000 4K ----- libcrypt-2.28.so
00007f6bc87cb000 4K r---- libcrypt-2.28.so
00007f6bc87cc000 4K rw--- libcrypt-2.28.so
00007f6bc87cd000 192K rw--- [ anon ]
00007f6bc8801000 28K r--s- gconv-modules.cache
00007f6bc8808000 4K r---- ld-2.28.so
00007f6bc8809000 120K r-x-- ld-2.28.so
00007f6bc8827000 32K r---- ld-2.28.so
00007f6bc882f000 4K r---- ld-2.28.so
00007f6bc8830000 4K rw--- ld-2.28.so
00007f6bc8831000 4K rw--- [ anon ]
00007ffc6026a000 132K rw--- [ stack ]
00007ffc60356000 16K r---- [ anon ]
00007ffc6035a000 4K r-x-- [ anon ]
total 14700K
The Windows version has the following loaded modules:

00007ff6`aefe0000 00007ff6`aeffa000 python python.exe


00007ff8`ef7e0000 00007ff8`efdad000 python311 python311.dll
00007ff9`62950000 00007ff9`6296b000 VCRUNTIME140
VCRUNTIME140.dll
00007ff9`7f1e0000 00007ff9`7f1ea000 VERSION VERSION.dll
00007ff9`8bce0000 00007ff9`8bd08000 bcrypt bcrypt.dll
00007ff9`8c3f0000 00007ff9`8c793000 KERNELBASE KERNELBASE.dll
00007ff9`8c840000 00007ff9`8c951000 ucrtbase ucrtbase.dll
00007ff9`8c960000 00007ff9`8c9db000 bcryptprimitives
bcryptprimitives.dll
00007ff9`8d150000 00007ff9`8d1c1000 WS2_32 WS2_32.dll
00007ff9`8d1d0000 00007ff9`8d2e7000 RPCRT4 RPCRT4.dll
00007ff9`8dd50000 00007ff9`8ddf7000 msvcrt msvcrt.dll
00007ff9`8ded0000 00007ff9`8df7e000 ADVAPI32 ADVAPI32.dll
00007ff9`8e1b0000 00007ff9`8e272000 KERNEL32 KERNEL32.DLL
00007ff9`8e280000 00007ff9`8e324000 sechost sechost.dll
00007ff9`8ef10000 00007ff9`8f124000 ntdll ntdll.dll

Memory Dump
A process memory can be saved in a memory dump file.

An undigested and voluminous mass of information about a problem or the state of a


system and most especially one consisting of hex runes describing the byte-by-byte
state of memory.
Eric S. Raymond, The New Hacker’s Dictionary, Third Edition

These memory dumps are also called core dumps in Linux. It is also possible to get a
kernel memory dump and a dump of physical memory (also called a complete memory
dump in Windows). Figure 1-5 shows different memory dump types.

Figure 1-5 Memory dump types

Memory dumps may be useful for debugging hard-to-reproduce intermittent


problems. This approach is called postmortem debugging. You will see some case studies
in the following chapters.

Crash
To fail suddenly. “Has the system just crashed?” “Something crashed the OS!” Also
used transitively to indicate the cause of the crash (usually a person or a program, or
both). “Those idiots playing SPACEWAR crashed the system.”
Eric S. Raymond, The New Hacker’s Dictionary, Third Edition.

When something illegal happens inside a process thread, such as when memory
outside its available range is accessed or you write to read-only memory, the operating
system reports the error and terminates the process. It may also save the process
memory into a memory dump file. The process then disappears from the list of available
processes.

Hang
1. To wait for an event that will never occur. “The system is hanging because it can’t
read from the crashed drive.”

2. To wait for an event to occur. “The program displays a menu and then hangs until
you type a character.”
Eric S. Raymond, The New Hacker’s Dictionary, Third Edition

Threads interact with other threads, including other processes’ threads. These
interactions can be viewed as sending messages and waiting for the responses. Some
processes may be critical because their threads process messages from many other
threads from other processes. If threads from such a critical process stop sending
responses, all other waiting threads are blocked. A deadlock is when two threads are
waiting for each other. When hanging, the process continues to be present in the list of
available processes. There are also processes (critical components) that, when their
threads hang, block threads from many other processes (noncritical components). Figure
1-6 depicts such components and their interaction abstracted via messages in the normal
scenario, and Figure 1-7 shows the abnormal scenario when noncritical components are
blocked and waiting for responses because the critical components are deadlocked.
Figure 1-6 Request and response interaction between critical and noncritical system components
Figure 1-7 Blocked and deadlocked components

Summary
In this chapter, you learned the fundamental vocabulary you will use in subsequent
chapters. The next chapter introduces a pattern-oriented debugging approach.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2024
D. Vostokov, Python Debugging for AI, Machine Learning, and Cloud Computing
https://doi.org/10.1007/978-1-4842-9745-2_2

2. Pattern-Oriented Debugging
Dmitry Vostokov1

(1) Dalkey, Dublin, Ireland

This chapter introduces the pattern-oriented debugging process


approach and the pattern languages you will use in subsequent
chapters.

The History of the Idea


The idea of using patterns in debugging is not new1. Earlier, such
patterns came in two types: bug patterns2 and debug patterns3. Before
2000, only a few debugging-related patterns could be found, such as the
Debug Printing Method4.
Bug patterns are usually specific patterns for specific languages and
platforms. By bugs, we mean software defects. Usually, these are related
to the source code but can also be related to configuration and data
models.
Using source code as a starting point for debugging is only possible
for a limited number of scenarios, such as when you have a Python
stack trace. However, there are many cases when the starting point for
source code investigation is unknown. Here, a well-defined process may
benefit. A number of debugging processes were proposed in the past,
including multidisciplinary approaches5.
The phrase “pattern-oriented debugging” appeared around 1987-
1988 in the context of patterns of process interaction6. It is not the
same as the “pattern-oriented debugging process” proposed in 20147
as further development of unified debugging patterns that were
introduced in 20108. Since then, these patterns have been used for
successfully teaching Windows debugging of unmanaged (native,
Win64, C, C++) and managed (.NET, C#) code9 for almost a decade,
starting in 2013. Overall, this pattern-oriented approach can be traced
to our earlier presentation published as a book in 201110. In it, we
apply the same pattern-oriented process to Python debugging in cloud
and machine learning environments.

Patterns and Analysis Patterns


Before looking at the debugging process, a few words about patterns in
the context of diagnostics and debugging. By a pattern, we mean a
common recurrent identifiable set of indicators (symptoms, signs). By
an analysis pattern, we mean a common recurrent analysis technique
and method of pattern identification in a specific context. By pattern
language, we mean common names of patterns and analysis patterns
used for communication.

Development Process
Let’s first look at the traditional software development process stages.
Figure 2-1 abstracts them from several development processes,
including waterfall and iterative ones.
Figure 2-1 Stages of the typical software development process

Development Patterns
For each stage, there exists some pattern language such as a vocabulary
of solutions to common recurrent identifiable problems with grammar,
semantics, and pragmatics. Figure 2-2 also includes software usage and
presentation patterns for human-computer interaction. In this book, I
assume you have familiarity with such pattern languages (some
references are provided below).
Figure 2-2 Typical software development pattern languages

Debugging Process and Patterns


The debugging process mirrors the development process and
development patterns, as shown in Figure 2-3. Let’s look at each stage.
Figure 2-3 Stages of the pattern-oriented debugging process

Elementary Diagnostics Patterns


Elementary software diagnostics patterns got inspiration from the
Elemental Design Patterns book title11, but they are different and
correspond to requirements from the software development process.
These are what software users experience, and the requirement is to
eliminate such experiences via debugging.
Debugging Analysis Patterns
You need to diagnose the right problem before doing any debugging.
Debugging analysis patterns correspond to software diagnostics. For
example, in memory dump analysis, there are analysis patterns such as
Managed Code Exception, Managed Stack Trace, Stack Overflow,
Deadlock, Spiking Thread, and many others. There are hundreds of
them12. Trace and log analysis patterns such as Thread of Activity,
Discontinuity, Time Delta, Counter Value, State Dump, and many
more are also included in this category13. We look at the most common
of them in Chapter 4.

Debugging Architecture Patterns


Debugging architecture patterns are partly inspired by POSA14, for
example, Debug Event Subscription/Notification. They are more
high-level than design patterns that may differ for specific technologies,
for example, object-oriented and functional.

Debugging Design Patterns


Debugging design patterns are partly inspired by the GoF design
pattern approach15, for example, Punctuated Execution.
Both debugging architecture and debugging design patterns pertain
to the development of debugging tools and to actual debugging
architectures and designs as reusable solutions to common recurrent
debugging problems in specific contexts.

Debugging Implementation Patterns


Debugging implementation patterns are patterns of debugging
strategies and core debugging techniques, such as Break-in, Code
Breakpoint, Data Breakpoint, and others covered in subsequent
chapters in Python debugging case studies.

Debugging Usage Patterns


Debugging usage patterns are about debugging pragmatics of reusable
debugging scenarios: how, what, when, and where to use the previous
debugging pattern categories, such as using data breakpoints in user
(process) and kernel space debugging.

Debugging Presentation Patterns


Debugging presentation patterns are about user interface and
interaction design16, for example, watch dialog. These patterns are also
related to debugging usage. We cover such patterns in the chapter
devoted to existing Python IDEs and their usage for Python debugging.
In our opinion, recent Python debugging books17 correspond to
debugging implementation, usage, and presentation. Automated
debugging18 belongs to debugging architecture and design. In this book,
we extract some of this knowledge into corresponding debugging
pattern languages, combine them with pattern-oriented software
diagnostics, and form a novel pattern-oriented Python debugging
approach in the context of machine learning and cloud computing
environments.

Summary
In this chapter, you learned about the pattern-oriented debugging
process, its stages, and corresponding pattern languages. The
subsequent chapters provide examples of debugging patterns from
each category from a Python programming perspective. The next
chapter is about the first stage and its patterns: elementary diagnostics
patterns.

Footnotes
1 Mehdi Amoui et al., “A Pattern Language for Software Debugging,” International
Journal of Computer Science, vol. 1, no. 3, pp. 218-224, 2006.
https://stargroup.uwaterloo.ca/~mamouika/papers/pdf/IJCS.2006
.pdf

2 Eric Allen, Bug Patterns in Java, 2002 (ISBN-13: 978-1590590614)


3 https://en.wikipedia.org/wiki/Debugging_pattern

4 Linda Rising, The Pattern Almanac 2000, p. 154 (ISBN-13: 978-0201615678)

5 Robert Charles Metzger, Debugging by Thinking: A Multidisciplinary Approach, 2003


(ISBN-13: 978-1555583071)

6 Alfred A. Hough and Janice E. Cuny, “Initial experiences with a pattern-oriented


parallel debugger.” PADD ‘88: Proceedings of the 1988 ACM SIGPLAN and SIGOPS
workshop on Parallel and distributed debugging November 1988 Pages 195–205
https://doi.org/10.1145/68210.69234

7 Dmitry Vostokov, Pattern-Oriented Debugging Process, in Theoretical Software


Diagnostics: Collected Articles, Third Edition, 2020 (ISBN-13: 978-1912636334), pp.
197-199

8 Ibid., “Analysis, Architectural, Design, Implementation and Usage Debugging


Patterns,” p. 129

9 Accelerated Windows Debugging 4D, Third Edition, 2022 (ISBN-13: 978-


1912636532)

10 Dmitry Vostokov, Introduction to Pattern-Driven Software Problem Solving, 2011


(ISBN-13: 978-1908043177)

11 Jason McC. Smith, Elemental Design Patterns, 2012 (ISBN-13: 978-0321711922)

12 Dmitry Vostokov, Encyclopedia of Crash Dump Analysis Patterns: Detecting


Abnormal Software Structure and Behavior in Computer Memory, Third Edition, 2020
(ISBN-13: 978-1912636303)
Other documents randomly have
different content
(3) At slow idle speed, or under approximately 20 miles per hour
road speed (in high gear), generator (green) signal light will
normally flash on and off, because at that speed generator voltage
output is very low and unsteady. CAUTION: Should generator
(green) signal light fail to go off at speed above approximately 20
miles per hour, generator is either not charging at all, or its current
output is not up to normal, and generator should be given attention
at once.

8. STOPPING THE ENGINE.


a. Stop engine only by turning ignition and light switch to off
(straight‐ahead) position, to prevent discharge of battery through
spark coil primary circuit.

9. OPERATION OF VEHICLE.
a. Starting on Level Ground. The engine having been warmed
up and checked for satisfactory operation, the vehicle (with operator
in riding position) is put in motion as follows:
(1) Transfer body weight to right leg.
(2) Fold back side stand (jiffy stand).
(3) Disengage clutch by depressing clutch foot pedal with heel of
left foot.
(4) Shift gear shifter lever into “1” (low) gear position.
(5) Slowly engage clutch by depressing clutch foot pedal with toe
of left foot.
(6) When clutch starts to “take hold,” open throttle sufficiently to
maintain engine speed.
(7) Accelerate gradually to between 12 and 15 miles per hour in
low gear.
(8) Close throttle quickly.
(9) Disengage clutch.
(10) Shift through “N” (neutral) position into “2” (second) gear.
(11) Reengage clutch and accelerate to about 25 miles per hour.
(12) Close throttle quickly.
(13) Disengage clutch.
(14) Shift into “3” (high) gear.
(15) Reengage clutch and accelerate to desired speed.
b. Starting on Uneven or Soft Ground.
(1) If standing on an incline or in loose, heavy ground, more
engine power will be required to start vehicle without stalling engine.
(2) It may be necessary to keep vehicle from rolling by keeping
pressure on front brake hand lever. Brake pressure is released after
vehicle starts in forward motion.
(3) Open throttle and engage clutch at same time to provide
power needed for starting, without racing engine unnecessarily.
(4) Motorcycle starts should be made without excessive
application of power, with consequent unnecessary spinning of rear
wheel.

10. DRIVING PRECAUTIONS.


a. Practice will enable a rider to judge at what rate of speed the
motorcycle should be moving before he shifts from a lower to higher
gear, and engine should never be permitted to labor unduly, when a
shift of gears, higher to lower, would improve operation.
(1) Operator must not look down at gear shifter when shifting
gears, but keep his eyes on the road ahead. Do not ride the clutch.
The operator’s foot should rest on clutch foot pedal only when he is
operating it. When shifting gears, disengage clutch fully to avoid
gear damage and shifting difficulties. CAUTION: Many transmissions
are ruined through failure to disengage clutch fully when shifting
gears.
b. Braking. Rear wheel service brake must be in such condition
that medium‐hard application will cause rear wheel to lock.
Application of service brake should be gradual, with just enough
force to accomplish desired result.
(1) Auxiliary front wheel brake, when used in conjunction with
service brake, must be applied with caution, especially on wet,
muddy, or slippery roads.
(2) After passing through water, the brakes should be set slightly,
and the vehicle operated for a short distance, until sufficient heat
has been generated to dry the brakes.
c. Avoid Low Gear Operation. Always operate vehicle in highest
gear possible, consistent with tactical situation, speed required,
power required, and kind and nature of road substance, to prevent
overheating of engine.
d. High Speed Tips. Only experienced riders should indulge in
high‐speed riding. A motorcycle operated for long distances at high
speed must be given closer than ordinary attention to avoid serious
engine overheating with consequent damage. For better motorcycle
service, apply the following suggestions:
(1) Develop habit of frequently snapping throttle shut for an
instant when running at high speed. This draws additional lubrication
to piston and cylinder and assists in cooling engine.
(2) In cool weather, operate engine slowly until it is thoroughly
warmed up, to avoid damage to pistons, rings, cylinders, and other
parts before oil is warm enough to circulate freely.
(3) If handle bar windshield and leg shields are used, engine is
more likely to overheat with continued high‐speed riding. Watch this
carefully.
(4) Adjust “steering damper” for best control of motorcycle
consistent with riding speed and condition and nature of road.
11. STOPPING AND PARKING VEHICLE.
a. Stopping Vehicle. Rider will make a “restart” easier and
quicker if he will apply the following instructions upon stopping
vehicle:
(1) Close throttle.
(2) Disengage clutch.
(3) Apply brake (or brakes) to slow vehicle without sliding rear
tire.
(4) Just before coming to a complete stop, shift into “N” (neutral)
position and engage clutch. CAUTION: If immediate restart is to be
made, shift into “1” (low) gear and allow clutch foot pedal to remain
in disengaged position. (Rider will be mounted on motorcycle with
engine running.)
(5) Continue brake application to complete stop.
(6) After vehicle slows to point where it can no longer be balanced
by steering, place left foot on ground to maintain balance until right
foot can be removed from brake operating pedal. CAUTION: Do not
idle engine longer than 1 minute.
(7) Stop engine by turning ignition switch off.
b. Parking Vehicle.
(1) Lean motorcycle on side (jiffy) stand.
(2) Shift into “1” (low) gear.
(3) Engage clutch so vehicle cannot roll.
(4) Shut off gasoline supply by turning valve (to right) finger‐tight
against its seat.

12. TOWING VEHICLE TO START ENGINE.


a. In emergencies when engine cannot be started with foot starter
crank, it can be started by towing the motorcycle.
(1) Set gear shifter lever in “2” (second) gear position.
(2) Disengage clutch.
(3) Choke carburetor.
(4) Turn ignition switch on.
(5) After momentum of the towed motorcycle reaches between 10
and 15 miles per hour, engage clutch, and continue procedure until
engine starts.
b. Engine Starting with Dead Battery. Emergency engine
starting with dead battery can be effected by making use of freshly
charged battery, or by towing as outlined above. If vehicle with dead
battery is to be towed for engine starting, proceed as follows:
(1) Disconnect battery negative wire from ground on right side of
motorcycle.
(2) Tow motorcycle for engine starting.
(3) After engine is started, reconnect battery ground wire to frame
to prevent damage to electrical system.

13. RUNNING‐IN NEW ENGINE (OR VEHICLE).


a. A new motorcycle engine or newly overhauled engine must be
given proper “break‐in” consideration for at least the first 1,000 to
1,200 miles of service. Failure to do this may result in damage that
will put engine out of active service within a short period of time.
b. At the first 250 miles, check front and rear drive chains to make
sure they are receiving required amount of oil for ample lubrication.
If necessary, have chain oilers adjusted by unit mechanic. Drive
chains must be inspected for correct adjustment, and be given
attention by unit mechanic as needed.
c. At first 500 miles, drain oil tank and refill with fresh oil. Check
front and rear chains (step b above). Thereafter, follow instructions
in Maintenance Operation section.
d. After a new motorcycle has been run 500 to 1,000 miles it
needs to be thoroughly checked over and any loose screws and nuts
tightened. Particular attention must be given engine and
transmission mounting bolts and nuts, and to rear wheel mounting
socket screws.
e. Following pointers must be observed when running‐in new
engine or newly overhauled engine:
(1) Do not exceed 30 miles per hour during first 100 miles.
(2) Do not exceed 35 miles per hour during next 200 miles.
(3) Do not exceed 40 miles per hour during next 400 miles.
(4) Do not exceed 50 miles per hour during next 500 miles.
(5) Avoid use of low gears during break‐in operation as much as
possible.
Section IV

FIRST ECHELON PREVENTIVE MAINTENANCE SERVICES

Paragraph
Purpose 14
Before‐operation service 15
During‐operation service 16
At‐halt service 17
After‐operation and weekly service 18

14. PURPOSE.
a. To insure mechanical efficiency it is necessary that the vehicle
be systematically inspected at intervals each day it is operated and
weekly, so that defects may be discovered and corrected before they
result in serious damage or failure. Certain scheduled maintenance
services will be performed at these designated intervals. The
services set forth in this section are those performed by driver or
crew before operation, during operation, at halt, after operation, and
weekly.
b. Driver preventive maintenance services are listed on the back
of “Driver’s Trip Ticket and Preventive Maintenance Service Record,”
W.D. Form No. 48, to cover vehicles of all types and models. Items
peculiar to specific vehicles, but not listed on W.D. Form No. 48, are
covered in manual procedures under the items to which they are
related. Certain items listed on the form that do not pertain to the
vehicle involved are eliminated from the procedures as written into
the manual. Every organization must thoroughly school each driver
in performing the maintenance procedures set forth in manuals,
whether or not they are listed specifically on W.D. Form No. 48.
c. The items listed on W.D. Form No. 48 that apply to this vehicle
are expanded in this manual to provide specific procedures for
accomplishment of the inspections and services. These services are
arranged to facilitate inspection and conserve the time of the driver,
and are not necessarily in the same numerical order as shown on
W.D. Form No. 48. The item numbers, however, are identical with
those shown on that form.
d. The general inspection of each item applies also to any
supporting member or connection, and generally includes a check to
see whether the item is in good condition, correctly assembled,
secure, or excessively worn.
(1) The inspection for “good condition” is usually an external
visual inspection to determine whether the unit is damaged beyond
safe or serviceable limits. The term “good condition” is explained
further by the following: not bent or twisted, not chafed or burned,
not broken or cracked, not bare or frayed, not dented or collapsed,
not torn or cut.
(2) The inspection of a unit to see that it is “correctly assembled”
is usually an external visual inspection to see whether it is in its
normal assembled position in the vehicle.
(3) The inspection of a unit to determine if it is “secure” is usually
an external visual examination, a hand‐feel, or a pry‐bar check for
looseness. Such an inspection should include any brackets, lock
washers, lock nuts, locking wires, or cotter pins used in assembly.
(4) “Excessively worn” will be understood to mean worn close to,
or beyond, serviceable limits, and likely to result in a failure if not
replaced before the next scheduled inspection.
e. Any defects or unsatisfactory operating characteristics beyond
the scope of first echelon to correct must be reported at the earliest
opportunity to the designated individual in authority.

15. BEFORE‐OPERATION SERVICE.


a. This inspection schedule is designed primarily as a check to see
that the vehicle has not been tampered with, or sabotaged since the
After‐operation Service was performed. Various combat conditions
may have rendered the vehicle unsafe for operation and it is the
duty of the driver to determine whether or not the vehicle is in
condition to carry out any mission to which it is assigned. This
operation will not be entirely omitted, even in extreme tactical
situations.
b. Procedures. Before‐operation Service consists of inspecting
items listed below according to the procedure described, and
correcting or reporting any deficiencies. Upon completion of the
service, results should be reported promptly to the designated
individual in authority.
(1) Item 1, Tampering and Damage. Look for any injury to vehicle in
general, its accessories or equipment, that may have been caused by
tampering, sabotage, collision, falling debris, or shell fire since
parking vehicle. Look for loosened or damaged accessories, loose
fuel or oil lines, or any disconnected linkage.
(2) Item 3, Fuel and Oil. Inspect tanks for fuel and oil levels, add oil
and fuel as necessary. Any appreciable change in levels since
performing After‐operation Service should be investigated and
reported to designated authority.
(3) Item 4, Accessories and Drives. Examine all accessories such as
carburetor, air cleaner, generator, and cut‐out relay for loose
connections, loose mountings, or leaks. Examine rear chain (final
drive) for free up‐and‐down movement (slack), midway between
sprockets. Total up‐and‐down movement must not be more than 1
inch, nor less than ½ inch. Inspect rear chain for adequate
lubrication.
(4) Item 6, Leaks, General. Examine vehicle and ground under
vehicle for indications of fuel or oil leaks. Normally a few drops of
waste oil from chains may be expected to drop from skid plate.
(5) Item 11, Glass. Clean glass on instruments; clean and adjust
rear view mirror; inspect glass for breakage.
(6) Item 12, Lamps. If tactical situation permits, observe whether
blackout and service lights operate with switch in its respective
positions, and go out when switched off. Also see that lights are
secure, and that lenses are clean and not broken. Observe whether
both filaments of service headlight operate when dimmer switch on
left handle bar is moved to its respective positions.
(7) Item 13, Wheels, Axle Nuts and Screws. Examine rear wheel
mounting socket screws, front and rear axle nuts, and front fork
rocker stud nuts for tightness. Observe rear chain adjusting screws
for secure locking. Inspect spokes for good condition and tightness.
(8) Item 14, Tires. Examine tires for cuts or imbedded objects in
treads or carcass. If time permits, check air pressure, which should
be 18 pounds front, and 20 pounds rear (tires cold). Inspect valve
caps for presence and secure mounting.
(9) Item 15, Springs and Suspension. Examine front fork springs for
secure mounting and good condition. Push down rear of saddle to
test for full action of saddle post spring.
(10) Item 16, Steering and Handle Bar Controls. Test steering head
bearing adjustment by exerting strong upward pull at handle bar
grips, and observing whether or not there is any noticeable play in
bearing. Operate steering damper lever and observe that damper is
compressed before lever reaches right‐side position, and is fully
released with lever in left‐side position. Test handle bar grip controls
for full, free action; also test for complete opening and closing of
throttle, and full advance and retard of timer.
(11) Item 17, Fenders (Mudguards), Luggage Carrier, Safety Guards,
and Stands. Examine these items for good condition and secure
mounting.
(12) Item 21, Tools and Equipment. Inspect tools and equipment for
presence, serviceability, and proper stowage. (See tool list in par.
21.)
(13) Item 7, Engine Warm‐up. Start engine, noting any tendency
toward hard starting, or improper action of foot starter crank. Set
throttle to moderate idle speed. Listen for unusual noises. Watch
instrument indications and engine performance, such as misfiring.
CAUTION: Do not idle engine longer than 1 minute with vehicle
standing.
(14) Item 8, Choke. During idling of engine, reset choke as required
to prevent excessive choking and dilution of engine oil.
(15) Item 9, Instruments. When switch is turned on and engine is
idling at moderate speed both red light (indicating oil pressure) and
green light (indicating generator action) should be out. At lower
operating speeds generator‐indicating light may flicker. CAUTION:
Do not operate engine with red light on (no oil pressure).
(16) Item 10, Horn. Tactical situation permitting, test horn.
(17) Item 22, Engine Operation. Engine should idle smoothly.
Accelerate and decelerate, listening for any unusual noises that may
indicate compression or exhaust leaks, worn, damaged, loose, or
inadequately lubricated engine parts, or accessories. Note any
unusual smoke from exhaust.
(18) Item 23, Driver’s Permit, Accident Report Form No. 26, and
Vehicle Manual. These items must be present on vehicle and safely
stowed.
(19) Item 25, During‐operation Service. The During‐operation Service
should start immediately after vehicle is put in motion, in the nature
of a road test.

16. DURING‐OPERATION SERVICE.


a. While vehicle is in motion, listen for any sounds such as rattles,
knocks, squeals, or hums that may indicate trouble. Be alert to
detect any odor of overheated components or units such as
generator, brakes, or clutch, fuel vapor from a leak in fuel system,
exhaust gas, or other signs of trouble. Any time the brakes are used,
gears shifted, or vehicle turned, consider this a test and notice any
unsatisfactory or unusual performance. Watch the instruments
constantly. Notice promptly any unusual instrument indication that
may signify possible trouble in system to which the instrument
applies.
b. Procedures. During‐operation Service consists of observing
items listed below according to the procedures following each item,
and investigating any indications of serious trouble. Notice minor
deficiencies to be corrected or reported at earliest opportunity,
usually at next scheduled halt.
(1) Item 27, Foot and Hand Brakes. The foot brake should operate
smoothly and effectively, leaving reserve pedal travel of 1 inch.
Normal free play before operation is 1 inch. Test hand brake lever for
free play, which should be ¼ of total handle travel. Test for ease and
smoothness of operation.
(2) Item 28, Clutch. Inspect clutch for disengagement at about ½
pedal travel. Clutch should not chatter, squeal, or slip.
(3) Item 29, Transmission. Gears should shift smoothly, operate
quietly, and not jump out of mesh during operation. If transmission
jumps out of mesh in any gear, this indicates need of shifter control
adjustment.
(4) Item 31, Engine and Controls. Be alert for deficiency in engine
performance such as lack of usual power, misfiring, unusual noise,
stalling, indication of engine overheating, or unusual exhaust smoke.
Notice whether engine responds to controls satisfactorily, whether
controls appear to be in proper adjustment and are sufficiently tight.
(5) Item 32, Instruments. Observe instruments for indication of
normal functioning of systems to which they apply.
(a) Speedometer and Odometer. Speedometer should indicate
vehicle speed without excessive noise or fluctuation. Odometer
should record trip and total mileage.
(b) Oil Pressure Signal Light. Red light should be off during
operation. If light goes on, stop vehicle and investigate for oil
pressure failure.
(c) Generator Signal Light. Green light should be off above 20
miles per hour. Battery discharge is indicated by green light being
on.
(6) Item 33, Steering. Adjust steering damper to desired steering
friction. Observe vehicle steering for wander, shimmy, leading to one
side, or wheel hop.
(7) Item 34, Running Gear. Listen for any unusual noises from
wheels, axles, or suspension parts that might indicate looseness or
damage.
(8) Item 35, Chassis. Be alert for noises that might indicate loose
accessories, controls, attachments, or equipment.

17. AT‐HALT SERVICE.


a. At‐halt Service may be regarded as minimum maintenance
procedures and should be performed under all tactical conditions,
even though more extensive maintenance services must be slighted
or omitted altogether.
b. Procedures. At‐halt Service consists of investigating any
deficiencies noted during operation, inspecting items listed below
according to the procedures following the items, and correcting any
deficiencies found. Deficiencies not corrected should be reported
promptly to the designated individual in authority.
(1) Item 38, Fuel and Oil. Replenish fuel and oil as may be required
to reach next refilling point. CAUTION: Left tank is for fuel; right
tank is for oil. Filler caps should not be interchanged, as only fuel
tank cap is vented.
(2) Item 39, Temperatures. Hand‐feel wheel hubs and brake drums
for overheating.
(3) Item 40, Vents. Make sure that crankcase breather outlet and
rear chain oil feed pipe are clear. Make sure grease drains in front
and rear brake side covers are open and clean.
(4) Item 42, Springs and Suspensions. Look for broken springs in fork.
(5) Item 43, Steering. Investigate any difficulty developed during
riding.
(6) Item 44, Wheels and Mounting Screws. Inspect wheels for broken,
bent, or loose spokes. Also, look for loose axle nuts or rear wheel
mounting screws. Inspect wheel rims for good condition.
(7) Item 45, Tires. Examine tires for low pressure or damage.
Remove foreign matter from tire treads; inspect for cuts.
(8) Item 46, Leaks, General. Inspect vehicle for indication of fuel, oil,
or battery leaks.
(9) Item 47, Accessories and Chain. Examine accessories for loose
connections, loose mountings, or damage. Examine rear drive chain
for broken rollers, broken link side plates, and broken or missing
connecting link spring clips. Inspect chain for adequate lubrication.
(10) Item 48, Air Cleaner. Air cleaner must be secure, with air
passages in good condition and clean. When operating under
extremely dusty or sandy conditions, inspect air cleaner frequently
and service as required.
(11) Item 49, Fenders (Mudguards), Luggage Carrier, Safety Guards,
and Stands. Inspect these items for looseness or damage.

(12) Item 52, Appearance and Glass. Clean windshield, rear view
mirror, and light lenses; inspect for good condition, secure
attachment, and broken glass.

18. AFTER‐OPERATION AND WEEKLY SERVICE.


a. After‐operation Service is particularly important, because at this
time the driver inspects his vehicle to detect any deficiencies that
may have developed, and corrects those he is permitted to handle.
He should report promptly, to the designated individual in authority,
the results of his inspection. If this schedule is performed
thoroughly, the vehicle should be ready to roll again on a moment’s
notice. The Before‐operation Service, with a few exceptions, is then
necessary only to ascertain whether the vehicle is in the same
condition in which it was left upon completion of the After‐operation
Service. The After‐operation Service should never be entirely
omitted, even in extreme tactical situations, but may be reduced to
the bare fundamental services outlined for the At‐halt Service, if
necessary.
b. Procedures. When performing the After‐operation Service, the
driver must remember and consider any irregularities noticed during
the day in the Before‐operation. During‐operation, and At‐halt
Services. The After‐operation Service consists of inspecting and
servicing the following items. Those items of the After‐operation
Services that are marked with an asterisk (*) require additional
Weekly services, the procedures for which are indicated in step (b)
of each applicable item.
(1) Item 54, Fuel and Oil. Fill fuel and oil tanks; fill oil tank within 1
inch of top; be sure to put oil in right tank and fuel in left tank; do
not interchange caps. CAUTION: When operating under extremely
dusty conditions, drain engine oil tank and refill with fresh oil as
frequently as excessive contamination of the oil occurs.
(2) Item 55, Engine Operation. Test for satisfactory engine idle
without stalling. Accelerate and decelerate engine, noting any
tendency to miss or backfire, unusual noises, or vibration that may
indicate worn parts, loose mounting, incorrect fuel mixture, or faulty
ignition. Investigate any unsatisfactory engine operating
characteristics noted during operation. Learn to recognize noise
caused by loose primary (front) drive chain. Slack in excess of ½
inch total up‐and‐down motion can cause excessive noise which
sounds like engine knock. Remove inspection cover for examination
of chain.
(3) Item 57, Horn. If tactical situation permits, test horn.
(4) Item 59, Lights. If tactical situation permits, observe whether
blackout and service lights operate with switch in its respective
positions, and go out when switched off. Also see that lights are
secure, and lenses clean and not broken. Observe whether both
filaments of service headlight operate when dimmer switch on left
handle bar is moved to its respective positions.
(5) Item 56, Instruments. Before stopping engine, inspect
instruments to see that indicator lights are still out. Stop engine.
After 30 seconds, turn on switch to see that oil pressure and
generator signal lights turn on. CAUTION: Be sure to turn off ignition
switch after this test.
(6) Item 58, Glass. Clean rear view mirror, windshield, instrument,
and light glass. Examine for secure mounting and breakage.
(7) Item 62, *Battery.
(a) Inspect battery carrier for good condition and secure
mounting. Inspect electrolyte level (should be 5⁄16 inch above
plates). Inspect for any signs of leakage of electrolyte indicating
battery has been overfilled, poorly sealed, or damaged. CAUTION:
Do not add water unless actually needed.
(b) Weekly. Clean dirt from top of battery, remove battery caps,
bring electrolyte level to 5⁄16 inch above plates, using clean,
drinkable water. Clean terminals or posts if corroded; be sure felt
washers are on terminals and properly oiled; tighten terminal bolts
cautiously, if loose. Clean and paint battery carrier if corroded.
(8) Item 63, *Accessories and Chain.
(a) Inspect carburetor, air cleaner, generator, and cut‐out relay for
loose connections, mountings, or damage. Examine rear drive chain
for broken rollers, broken link side plates, and broken or missing
connecting link spring clips. Examine rear chain (final drive) for free
up‐and‐down movement (slack) midway between sprockets;
maximum total allowable deflection is 1 inch, minimum, ½ inch.
(b) Weekly. Tighten any accessory connections found loose. Wipe
excess dirt from rear chain. Check front chain for adjustment, and
inspect for proper lubrication.
(9) Item 65, *Air Cleaner.
(a) Examine oil cup for excessive dirt and correct oil level. If air
cleaner is excessively dirty, clean elements in dry‐cleaning solvent,
refill cup with fresh oil. Dip elements in oil in oil cup, replacing
elements and attaching oil cup immediately. If gaskets are damaged,
replace. Under extremely dusty or sandy conditions it may be
necessary to clean and refill the air cleaner more than once daily.
Inspect hose for leaks.
(b) Weekly. Inspect air cleaner for proper oil level and excessively
dirty oil. Clean and service air cleaner, tighten mounting and hose
clamps. NOTE: Early‐type, round air cleaner does not have
removable filter elements. Complete cleaner must be removed to
wash element.
(10) Item 66, *Fuel Filter (Gasoline Strainer).
(a) Clean cap and screen of fuel filter.
(b) Weekly. Clean cap and screen of fuel filter, remove carburetor
bowl drain plug, and drain off water and dirt. Be sure to replace
plug, being careful to avoid cross threading.
(11) Item 67, Engine Controls. Examine throttle and spark controls
for damage to wires or for disconnected linkage. Observe for lack of
lubrication.
(12) Item 68, *Tires.
(a) Remove foreign matter such as nails, glass, or stones from tire
treads. Inspect tires for abnormal tread wear, cuts, or bruises: also
for presence and tightness of valve caps. Inflate tires to 18 pounds
front, 20 pounds rear, with tires cool.
(b) Weekly. Replace badly worn or otherwise unserviceable tires.
(13) Item 69, *Springs and Suspension.
(a) Inspect front fork for broken or sagged springs, loose bolts,
studs, and nuts.
(b) Weekly. Tighten wheel axle nuts and rear brake sleeve nut.
Also tighten rear wheel mounting socket screws very securely.
(14) Item 70, Steering. Inspect steering head for proper adjustment
of bearings. Examine steering damper for correct adjustment.
(15) Item 72, *Vents.
(a) Make sure that crankcase breather outlet and rear chain oil
supply pipe are clear. Make sure grease drains in front and rear
brake side covers are open and clean.
(b) Weekly. Clean crankcase breather outlet, rear chain oil supply
pipe, and grease drains in front and rear brake side covers.
(16) Item 73, Leaks, General. Look around mechanism and beneath
vehicle for indication of fuel, oil, and grease leaks. Examine around
brake drums for evidence of grease in drums or on linings. Normally
a few drops of oil may be expected to drip from skid plate.
(17) Item 74, Gear Oil Levels. Inspect transmission oil level with
vehicle standing on rear stand (not jiffy stand); refill, if required, to
level of filler plug opening with engine oil. CAUTION: Do not use
gear oil.
(18) Item 76, Fenders (Mudguards), Luggage Carrier, Safety Guards,
and Stands. Examine these items for good condition and secure
mounting.
(19) Item 82, *Tighten.
(a) Inspect all frame and assembly nuts, bolts, and cap screws for
tightness.
(b) Weekly. Tighten all vehicle assembly or mounting nuts. Driver
is cautioned not to tamper with or tighten screws or nuts about the
circuit breaker, as doing so may disturb ignition timing.
(20) Item 83, *Lubricate as Needed.
(a) Lubricate all parts where inspection reveals need for
lubrication: wipe all dirt from fittings before applying lubricant.
Report any missing fittings.
(b) Weekly. When vehicle has been driven a sufficient number of
miles so that it is due for a regularly scheduled lubrication, lubricate
according to Lubrication Guide in manual and current lubrication
directives. Refrain from overlubricating wheel bearings, front brake
side cover bushing, and front and rear brake operating lever
camshafts.
(21) Item 84, *Clean Engine and Vehicle.
(a) Clean dirt and trash from vehicle and remove excess grease.
(b) Weekly. Wash vehicle if possible. If not, wipe off thoroughly.
Do not rub lustreless paint enough to cause shine. If vehicle is
washed in a stream, care should be taken that water or dirt does not
get into bearings, breather valve, or brakes. CAUTION: It is
extremely important that high‐pressure streams or steam should not
be directed against wheel hubs, brakes, carburetor, air cleaner, or
electrical units.
(12) Item 64, *Electrical Wiring.
(a) Inspect all ignition wiring to see that it is securely connected,
clean, and not damaged.
(b) Weekly. Inspect all wiring to see that it is securely connected
and supported, that insulation is not cracked or chafed, that loom,
shielding, and condensers are in good condition and securely
attached. Clean as required. Tighten any loose connections carefully.
Radio shielding or bonding defects, except cleaning or tightening,
must be referred to signal corps personnel.
(23) Item 85, *Tools and Equipment.
(a) See that all tools and equipment assigned to vehicle are
present, in good condition, and properly stowed.
(b) Weekly. Check tools and equipment assigned to vehicle with
vehicle stowage list (par. 21) to see that they are present. Inspect
tools for good condition and proper stowage. Report missing or
unserviceable items to designated authority.
Section V

LUBRICATION

Paragraph
Introduction 19
Lubrication guide 20

19. INTRODUCTION.
a. Lubrication is an essential part of preventive maintenance,
determining to a great extent serviceability of parts and assemblies.

20. LUBRICATION GUIDE (fig. 10).


a. General. Lubrication instructions for this materiel are
consolidated in a Lubrication Guide (fig. 10). These specify the
points to be lubricated, the periods of lubrication, and the lubricant
to be used. Intervals indicated on the guide are for normal service.
For extreme conditions, high speed, heat, mud, snow, rough roads,
dust, etc., change engine oil and lubricate more frequently. In
addition to the items on the guide, brake, gear shifter, clutch control
linkage, and hinges must be lubricated at frequent intervals.
b. Supplies. In the field it may not be possible to supply a
complete assortment of lubricants called for by the Lubrication Guide
to meet the recommendations. It will be necessary to make the best
use of those available, subject to inspection by the officer
concerned, in consultation with responsible ordnance personnel.
c. Lubrication Notes. The following notes apply to the
Lubrication Guide (fig. 10). All note references in the guide itself are
to the steps below having the corresponding number:
(1) Brake Fittings. Exercise caution when lubricating brake
operating cams and front brake cover bushing, as excess grease
working out of these bearings is likely to get onto brake lining,
reducing brake efficiency. CAUTION: When using air‐operated grease
gun, make sure not to overlubricate brake fittings.
(2) Brake Hand Lever Oilcan Points. Oil hand lever fittings and “oiler”
mounted on cable housing. Oil front brake control cable at ends of
control cable housing.
(3) Generator Commutator End Bearing. Hand‐pack with general
purpose grease, No. 2, at temperatures above zero. Below zero, use
lighter grease. This operation requires removal of generator end
cover. Bearing outer grease retainer must be loosened and swung
aside for access to bearing. If not convenient to grease bearing at
specified intervals, at least lubricate with a few drops of engine oil
applied to hole in outer grease retainer. Do not overlubricate.
CAUTION: Generator regulating brush plate must not be shifted
while bearing outer grease retainer is loose (par. 92). Generator
drive end bearing requires no attention, since it is lubricated by oil
circulating through engine.
—— KEY ——
INTERVALS
LUBRICANTS ¼— 250 MILES
OIL, ENGINE (CRANKCASE
OE — ½— 500 MILES
GRADE)
CG — GREASE, GENERAL PURPOSE 1 — 1000 MILES
No. 1 (ABOVE +32°) 6 — 6000 MILES
SPECIAL
No. 1 OR No. 0 (+32° TO +10°) * L—
LUBRICATION
No. 0 (BELOW +10°) CHECK DAILY
GREASE, GENERAL PURPOSE
WB — Air Cleaner
(No. 2)
Engine Oil Tank

TABLE OF CAPACITIES WITH RECOMMENDATIONS AT


TEMPERATURES SHOWN
ABOVE +32° TO BELOW
UNIT CAPACITY
+32° +10° +10°
OE OE OE
OIL TANK 1 GALLON
S.A.E. 50 S.A.E. 30 S.A.E. 10
OE OE OE
TRANSMISSION ¾ pint
S.A.E. 50 S.A.E. 30 S.A.E. 10

RA PD 310207
Figure 10—Lubrication Guide

(4) Spark and Throttle Control Grips. These grips require


disassembly. Twice a year, or whenever grips do not turn freely,
indicating need of lubrication, remove grips, clean parts, apply
grease, and reassemble (par. 101).
(5) Air Cleaner. Examine oil cup daily for excessive dirt and correct
oil level. Under extremely dusty or sandy conditions it may be
necessary to clean and refill the air cleaner more than once daily.
Refill oil cup to indicated level with engine oil. Drain, clean, and refill
oil cup every 250 miles, depending upon operating conditions. Every
1,000 miles (oftener if necessary), remove air cleaner filter units,
wash in dry‐cleaning solvent, lubricate, and reassemble (par. 76).
NOTE: Early type round cleaner did not have removable filter
element. Complete cleaner must be removed to wash element.
(6) Wheel Bearings. When wheel hubs are lubricated at regular
500‐mile interval, 1⁄8 ounce of grease with each greasing is
sufficient. This amounts to about 15 shots of the standard 1‐pound
air gun, or four strokes with a 1‐pound, hand‐operated gun. If
vehicle has been operated in water, wheel hubs submerged, apply
hub greasing service immediately afterward (or soon as situation
permits). Do not overlubricate wheel hub bearings, as excess grease
may work into brake linings, reducing brake efficiency. When using
air‐operated grease gun, it is easy to overlubricate wheel hub
bearings.
(7) Steering Head Bearings. Every 50,000 miles, repack upper and
lower bearings, or whenever there is occasion to remove rigid fork
for repair or replacement (par. 98).
(8) Tank, Engine Oil. Oil tank is located on right side of motorcycle.
Empty tank holds 1 U. S. gallon. Check daily and add engine oil as
necessary to refill tank within 1 inch of top. Oil level gage rod (dip
stick) is located directly below tank cap. When oil level is down to
“REFILL” mark on gage rod, 2 U. S. quarts may be added. Drain oil
tank every 1,000 miles and refill with fresh engine oil. Drain plug
located on underside of tank in forward position. In extremely dusty
service, and in winter weather, change oil oftener.
(a) Winter Caution. Water is a by‐product of combustion in any
internal combustion engine. In a condensed state, the water vapor
formed would equal approximately the quantity of gasoline burned.
Some of this water vapor escapes past the rings into the crankcase.
When starting and warming up in cold weather, considerable vapor
getting into crankcase condenses to water before crankcase is hot
enough to exhaust the vapor, without inside condensation, through
outside breather. If engine is driven enough to get crankcase
thoroughly warmed up frequently, most of this water is again
vaporized and blown out through outside breather. However, a
moderately driven engine, making only short runs now and then,
and seldom thoroughly warmed up, is likely to accumulate an
increasing amount of water in oil tank. This water will, in freezing
weather, become slush or ice and, if allowed to accumulate too long,
may block oil lines with resulting damage to engine. Also, water
mixed with oil for some time, forms a heavy sludge of considerable
acid content that is very harmful to bearings and other internal
engine parts. To sum it up briefly, an engine that is used only for
short runs during freezing weather requires frequent oil changes
along with thorough flushing of tank to remove any accumulated
sludge.
(9) Transmission Filler Opening. Check oil level in transmission case
every 250 miles and add engine oil as necessary to bring level up to
filler opening. If motorcycle is run unusually long distances, inspect
more frequently. Motorcycle must be on rear stand in straight
upright position when checking oil level or filling transmission case.
Use same grade of oil used in engine, summer, and winter. If gear
shifting difficulty is caused by oil congealing in extremely cold
weather, thin oil with small amount of kerosene or dry‐cleaning
solvent. Every 1,000 miles, drain and refill transmission to level of
transmission filler plug opening with specified grade of engine oil.
Transmission holds ¾ pint of oil. To drain transmission case remove
filler plug and lay motorcycle on right side. CAUTION: Do not leave
motorcycle on side longer than two minutes.
(10) Drive Chains.
(a) Front and rear drive chains are automatically supplied with
lubrication by engine oil pumps. Chain oilers are adjustable and may
need occasional readjustment to meet lubrication requirements of
varied operating conditions. Every 1,000 miles (or more often if
operating conditions are extremely severe) inspect front primary
drive chain for adequate lubrication (fig. 36).
(b) At every 1,000‐mile period rear drive chain should have
additional lubrication as follows: Remove chain, wash thoroughly in
dry‐cleaning solvent and hang it up to dry. Then soak chain in SAE
10 engine oil for a short period of time to allow oil to penetrate into
all chain bearings. Drain chain and wipe off excess oil. Install rear
chain (par. 63). (This attention is not required by front chain.)
Readjustment of chain oilers must be made only by organization
mechanic (par. 61). CAUTION: Inspect frequently and make sure
that rear chain oiler supply pipe is clear, not bent or damaged.
d. Before Applying Lubricant. Always wipe dirt from the
lubrication fittings or plugs so that dirt will not enter with the
lubricant. Lubricate all chassis points after washing vehicle or after
vehicle has been operated in streams or extremely muddy or slushy
roads. CAUTION: It is extremely important that high‐pressure
cleaning streams or steam should not be directed against ends of
wheel hubs, brake side cover bearings, air cleaner, handle bar grips,
or electrical system. To do so will seriously affect correct lubrication
and functioning of these parts.
e. Oilcan Points. All brake, transmission, and clutch control
points not fitted with grease connections should be lubricated with
engine oil. Front brake control cable, spark, and throttle control
wires must be oiled at the ends of their respective housings,
especially after washing vehicle, or after operating it in wet weather.
Keep battery terminal felt washers saturated with engine oil to
prevent corrosion of connections.
f. Warning Light. Action of the engine oil feed pump is indicated
by red signal light in instrument panel. Rider must be thoroughly
familiar with operating characteristics of this signal light, to judge
condition of engine oil circulating system (par. 7 f).
Section VI

TOOLS AND EQUIPMENT STOWAGE ON THE VEHICLE

Paragraph
Vehicle tools 21
Vehicle equipment 22
Vehicle spare parts 23

RA PD 310208
Figure 11—Vehicle Tools

21. VEHICLE TOOLS (fig. 11).


a. Kits. Included in the tool kit assembly are the following:

Legend
Letter Federal
for Number Mfr’s Stock Where
Fig. 11 Tool Carried Number Number Carried
A 11819– In saddle
Tool roll
1 44 —— bag
B 11551– 41–I–773– In tool
Irons, tire
2 X 75 roll
*C 11817– 41–H– In tool
Handle, chain tool
1 40 1510–400 roll
D Wrench, 8–in. by ¾–
5⁄
11804– In tool
in. 1 44C —— roll
E Wrench, ½–in. by 9⁄16– 11804– In tool
in. 1 44B —— roll
F Wrench, 7⁄16–in. by ½– 11804– In tool
in. 1 44A —— roll
G Wrench, 5⁄16–in. by 3⁄8– 11804– In tool
in. 1 44 —— roll
H Wrench, ⅜–in. by 7⁄16– 11905– In tool
in. (valve tappet) 1 X —— roll
I 11813– In tool
Wrench, adjustable
1 44 —— roll
*J Wrench, ¾–in. by 1¾–
in. (rear axle nut 11814– 41–W– In tool
and trans.) 1 35 1989–850 roll
K 11562– In tool
Gage, tire
1 43 —— roll
*L 12039– In tool
Tool, chain repair
1 38 —— roll
*M Washers, 0.002–in.
thick (chain oiler 674– In tool
adj.) 4 32 —— roll
*N Wrench, 7⁄16–in. by
1⅜–in. (valve 11806– 41–W– In tool
cover) 1 31 3617 roll
*O Wrench, 7⁄16–in. by
11⁄8–in. (use with 11929– In tool
spark plug socket) 1 39 —— roll
*P 11812– In tool
Pliers, adjustable
1 44 —— roll
*Q 11811– In tool
Screwdriver
1 X —— roll
R Wrench, 9⁄16–in. socket 12047– 41– In tool
(cyl. head bolt) 1 30A W01525 roll
*S Wrench, wheel 11815– 41–W– In tool
mounting 1 35 3825–400 roll
*T Wrench, socket (spark 11805– 41–W– In tool
plug; use with O) 1 40 3332 roll
On
Pump, tire 11553– frame,
1 41M 8–P–4900 left side
11661– In saddle
Grease gun (in case)
1 38A —— bag
*EXCEPTION: Earlier models furnished with smaller tool roll and
kit contain the items marked by asterisk.

22. VEHICLE EQUIPMENT (figs. 12 and 13).


a. Attached to Vehicle.

Number
Item
Carried Where Carried
Saddlebags 2 On luggage carrier
Mirror, rear view 1 On left handle bar
Box, submachine gun
ammunition 1 Front fender, left side
Bracket, submachine gun carrier Front fender, right
1 side
Guard, front safety 1 Attached to frame
Guard, rear safety 1 Attached to frame
Windshield, cpt 1 On handle bar
Leg shields, cpt (right and left) 2 Attached to frame
RA PD 310216
Figure 12—Vehicle Equipment, Left Side
RA PD 310217
Figure 13—Vehicle Equipment, Right Side
RA PD 310209
Figure 14—Vehicle Spare Parts

23. VEHICLE SPARE PARTS (fig. 14).


3a. Spare Parts.

Item Number Carried Where Carried


A Roll, parts kit 1 In saddlebag
H Plug, spark (and gasket) 1 In kit roll
F Link, rear chain repair 1 In kit roll
G Link, front chain repair 1 In kit roll
K Lamp‐unit, tail blackout 1 In kit roll
J Lamp‐unit, stop blackout 1 In kit roll
L Lamp‐unit, tail and stop 1 In kit roll
B Lamp bulk kit, head lamps, 5 bulbs 1 In kit roll
C Kit, tire repair 1 In kit roll
I Tape, friction 1 In kit roll
D Caps, tire valve (5 in box) 1 In kit roll
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookmasss.com

You might also like