Mercurial > hg > index.cgi
annotate lwasm/input.h @ 577:e49d24f4a9a5
Correct bug in the object file output code leading to stack corruption
It turns out leaving a pointer to a stack allocated temporary in a
persistent data structure is not conducive to correct program operation.
Undo the export check setup in the object file output sequence so a
pointer to stack allocated memory is not left hanging when the function
returns. This seems to correct at least one mysterious crash bug, and
possibly others.
Thanks to Boisy Pitre for reporting the crash bug that led to this
discovery, as well as a previous crash bug that likely has the same
root cause.
Additional thanks to Ciaran Anscomb whose debugger wielding wizardry
revealed the exact location of this particular bit of unbrilliance.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sat, 03 Aug 2024 14:30:06 -0600 |
parents | dd9c5cef2e80 |
children |
rev | line source |
---|---|
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1 /* |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
2 input.h |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
3 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
4 Copyright © 2010 William Astle |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
5 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
6 This file is part of LWTOOLS. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
7 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
8 LWTOOLS is free software: you can redistribute it and/or modify it under the |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
9 terms of the GNU General Public License as published by the Free Software |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
10 Foundation, either version 3 of the License, or (at your option) any later |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
11 version. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
12 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
13 This program is distributed in the hope that it will be useful, but WITHOUT |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
16 more details. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
17 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License along with |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
19 this program. If not, see <http://www.gnu.org/licenses/>. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
20 */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
21 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
22 #ifndef ___input_h_seen___ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
23 #define ___input_h_seen___ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
24 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
25 #include "lwasm.h" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
26 |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
0
diff
changeset
|
27 typedef struct |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
0
diff
changeset
|
28 { |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
0
diff
changeset
|
29 int magic; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
0
diff
changeset
|
30 } input_stack_entry; |
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
0
diff
changeset
|
31 |
374 | 32 void input_stack_push(asmstate_t *as, input_stack_entry *se); |
33 input_stack_entry *input_stack_pop(asmstate_t *as, int magic, int (*fn)(input_stack_entry *e, void *data), void *data); | |
108
9960e05cbe3a
Added *pragmapush and *pragmapop; still seems to be nonfunctional
lost@l-w.ca
parents:
0
diff
changeset
|
34 |
374 | 35 void input_init(asmstate_t *as); |
36 void input_openstring(asmstate_t *as, char *s, char *str); | |
37 void input_open(asmstate_t *as, char *s); | |
38 char *input_readline(asmstate_t *as); | |
39 char *input_curspec(asmstate_t *as); | |
40 FILE *input_open_standalone(asmstate_t *as, char *s, char **rfn); | |
379
d791d47afc48
Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents:
374
diff
changeset
|
41 int input_isinclude(asmstate_t *as); |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
108
diff
changeset
|
42 |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
108
diff
changeset
|
43 struct ifl |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
108
diff
changeset
|
44 { |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
108
diff
changeset
|
45 const char *fn; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
108
diff
changeset
|
46 struct ifl *next; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
108
diff
changeset
|
47 }; |
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
108
diff
changeset
|
48 |
507 | 49 extern struct ifl *ifl_head; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
50 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
51 #endif |