Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
2fe841d2
Commit
2fe841d2
authored
10 years ago
by
Dave Hylands
Browse files
Options
Downloads
Patches
Plain Diff
Try not to cause a MemoryError when raising an exception during nterrupt handling.
Step 1 fixes #732
parent
8993fb6c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/gc.c
+4
-0
4 additions, 0 deletions
py/gc.c
py/gc.h
+1
-0
1 addition, 0 deletions
py/gc.h
py/objexcept.c
+5
-0
5 additions, 0 deletions
py/objexcept.c
with
10 additions
and
0 deletions
py/gc.c
+
4
−
0
View file @
2fe841d2
...
...
@@ -172,6 +172,10 @@ void gc_unlock(void) {
gc_lock_depth
--
;
}
bool
gc_is_locked
(
void
)
{
return
gc_lock_depth
!=
0
;
}
#define VERIFY_PTR(ptr) ( \
(ptr & (BYTES_PER_BLOCK - 1)) == 0
/* must be aligned on a block */
\
&& ptr >= (machine_uint_t)gc_pool_start
/* must be above start of pool */
\
...
...
This diff is collapsed.
Click to expand it.
py/gc.h
+
1
−
0
View file @
2fe841d2
...
...
@@ -30,6 +30,7 @@ void gc_init(void *start, void *end);
// They can be used to prevent the GC from allocating/freeing.
void
gc_lock
(
void
);
void
gc_unlock
(
void
);
bool
gc_is_locked
(
void
);
// A given port must implement gc_collect by using the other collect functions.
void
gc_collect
(
void
);
...
...
This diff is collapsed.
Click to expand it.
py/objexcept.c
+
5
−
0
View file @
2fe841d2
...
...
@@ -37,6 +37,7 @@
#include
"objtype.h"
#include
"runtime.h"
#include
"runtime0.h"
#include
"gc.h"
typedef
struct
_mp_obj_exception_t
{
mp_obj_base_t
base
;
...
...
@@ -335,6 +336,10 @@ void mp_obj_exception_clear_traceback(mp_obj_t self_in) {
}
void
mp_obj_exception_add_traceback
(
mp_obj_t
self_in
,
qstr
file
,
machine_uint_t
line
,
qstr
block
)
{
if
(
gc_is_locked
())
{
// We can't allocate memory, so don't bother to try
return
;
}
GET_NATIVE_EXCEPTION
(
self
,
self_in
);
// for traceback, we are just using the list object for convenience, it's not really a list of Python objects
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment