From: Sebastian Humenda <shumenda@gmx.de>
To: edbrowse-dev@edbrowse.org
Subject: Re: uninitialized globals
Date: Fri, 5 Apr 2024 12:43:09 +0200 [thread overview]
Message-ID: <Zg_Vvf27Bnlv3w2L@kraftkrust> (raw)
In-Reply-To: <20240305042901.eklhad@comcast.net>
[-- Attachment #1: Type: text/plain, Size: 12304 bytes --]
Hi
Pardon, I should have sent it to the list.
Karl Dahlke schrieb am 05.04.2024, 4:29 -0400:
>the latest edbrowse 3.8.9 on Debian, compiled with GCC 12.2. It segfaults on
>startup, and the backtrace suggests it is in main.c:1926, where it nzFree's
[…]
[…]
An excerpt of the build output is below this e-mail; it includes the build
flags.
>I am rather stunned by this. I have been using C since 1980. Ever since the
>original K&R, global uninitialized variables are 0. I don't understand how
[…]
I am bored by C standards and alike. I have been writing MISRA C for several
years and I do remember the checkre requiring us to initialise explicitly
every static (i.e. global) as its initialisation was either depending on the
type or implementation defined, I do not recall.
Here is what nm says:
% nm src/edbrowse | grep 'sslCerts'
0000000000247088 D sslCerts
% nm src/edbrowse | fgrep allowJS
% nm src/edbrowse | fgrep allowJS
0000000000247079 D allowJS
>but that's not simple because there are dozens of global variables, and some
>static variables too, that are not initialized, that I count on being zero.
>If we got past sslCerts we would just run into another one. We'd have to
[…]
Agreed. I actually just looked whether I can call up my.test.website and with
this set, it worked :). I actually was trying out the QuicJS support.
Cheers
Sebastian
=== Build Output
cc -g -O2 -ffile-prefix-map=/tmp/edbrowse=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-unused -D_FILE_OFFSET_BITS=64 -DEDBROWSE_ON_LINUX -I/usr/include/x86_64-linux-gnu -g -ggdb -Wextra -Wdate-time -D_FORTIFY_SOURCE=2 -c -o dbodbc.o dbodbc.c
isup.c: In function ‘decodePostData’:
isup.c:1276:30: warning: ‘c’ may be used uninitialized [-Wmaybe-uninitialized]
1276 | *w++ = c;
| ~~~~~^~~
isup.c:1230:14: note: ‘c’ was declared here
1230 | char c;
| ^
css.c: In function ‘hashSortCrunch’:
css.c:3222:37: warning: ‘j’ may be used uninitialized [-Wmaybe-uninitialized]
3222 | mark->body[j++] = v->t;
| ~^~
css.c:3202:16: note: ‘j’ was declared here
3202 | int i, j, distinct = 0;
| ^
css.c: In function ‘do_rules’:
css.c:3106:9: warning: ‘tn’ may be used uninitialized [-Wmaybe-uninitialized]
3106 | set_property_bool_t(tn, "inj$css", true);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
css.c:2957:20: note: ‘tn’ was declared here
2957 | const Tag *tn; // the text node that holds before or after text
| ^~
dbops.c: In function ‘stringDate’:
dbops.c:505:17: warning: ‘__builtin_strncpy’ output may be truncated copying 4 bytes from a string of length 7 [-Wstringop-truncation]
505 | strncpy(buf, buf + 4, 4);
| ^
dbodbc.c: In function ‘retsFromOdbc’:
dbodbc.c:937:30: warning: ‘input_length’ may be used uninitialized [-Wmaybe-uninitialized]
937 | rc = SQLGetData(hstmt, (ushort) (i + 1),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
938 | c_type, q1, input_length,
| ~~~~~~~~~~~~~~~~~~~~~~~~~
939 | &output_length);
| ~~~~~~~~~~~~~~~
dbodbc.c:827:14: note: ‘input_length’ was declared here
827 | long input_length, output_length;
| ^~~~~~~~~~~~
dbodbc.c:937:30: warning: ‘c_type’ may be used uninitialized [-Wmaybe-uninitialized]
937 | rc = SQLGetData(hstmt, (ushort) (i + 1),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
938 | c_type, q1, input_length,
| ~~~~~~~~~~~~~~~~~~~~~~~~~
939 | &output_length);
| ~~~~~~~~~~~~~~~
dbodbc.c:826:15: note: ‘c_type’ was declared here
826 | short c_type; /* C data type */
| ^~~~~~
dbops.c: In function ‘stringTime’:
dbops.c:636:28: warning: ‘c’ may be used uninitialized [-Wmaybe-uninitialized]
636 | if (c == 'A')
| ^
dbops.c:593:14: note: ‘c’ was declared here
593 | char c;
| ^
css.c: In function ‘cssParseLeft’:
css.c:1336:52: warning: ‘sel2’ may be used uninitialized [-Wmaybe-uninitialized]
1336 | sel2->next = sel, sel2 = sel;
| ~~~~~~~~~~~^~~~~
css.c:1258:21: note: ‘sel2’ was declared here
1258 | struct sel *sel2;
| ^~~~
dbodbc.c: In function ‘oneRetValue.constprop’:
dbodbc.c:1114:19: warning: ‘f’ may be used uninitialized [-Wmaybe-uninitialized]
1114 | n = f;
| ~~^~~
dbodbc.c:1097:16: note: ‘f’ was declared here
1097 | double f;
| ^
dbodbc.c:1126:19: warning: ‘c’ may be used uninitialized [-Wmaybe-uninitialized]
1126 | n = c;
| ~~^~~
dbodbc.c:1095:14: note: ‘c’ was declared here
1095 | char c;
| ^
dbodbc.c:1133:16: warning: ‘n’ may be used uninitialized [-Wmaybe-uninitialized]
1133 | return n;
| ^
dbodbc.c:1096:14: note: ‘n’ was declared here
1096 | long n;
| ^
dbops.c: In function ‘lineFormatStack’:
dbops.c:191:40: warning: ‘dn’ may be used uninitialized [-Wmaybe-uninitialized]
191 | (pdir == 'f' && dn == nullfloat) ||
dbops.c:101:16: note: ‘dn’ was declared here
101 | double dn; /* double number */
| ^~
dbops.c:189:37: warning: ‘n’ may be used uninitialized [-Wmaybe-uninitialized]
189 | if ((pdir == 'c' && !n) ||
| ^~
dbops.c:100:14: note: ‘n’ was declared here
100 | long n;
| ^
css.c: In function ‘cssPieces’:
css.c:1008:42: warning: ‘d2’ may be used uninitialized [-Wmaybe-uninitialized]
1008 | d2->next = d, d2 = d;
| ~~~~~~~~~^~~
css.c:802:31: note: ‘d2’ was declared here
802 | struct desc *d1 = 0, *d2, *d = 0;
| ^~
In function ‘uncomment’,
inlined from ‘cssPieces’ at css.c:815:2:
css.c:176:56: warning: ‘url0’ may be used uninitialized [-Wmaybe-uninitialized]
176 | *w++ = *u;
| ^~
css.c: In function ‘cssPieces’:
css.c:147:23: note: ‘url0’ was declared here
147 | char *w = s, *url0;
| ^~~~
cc -I/usr/include/quickjs -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -ffile-prefix-map=/tmp/edbrowse=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-unused -D_FILE_OFFSET_BITS=64 -DEDBROWSE_ON_LINUX -I/usr/include/x86_64-linux-gnu -g -ggdb -Wextra -c jseng-quick.c
In function ‘cursor_comm’,
inlined from ‘syncup_table’ at dbops.c:2051:2:
dbops.c:1945:31: warning: ‘sortval2’ may be used uninitialized [-Wmaybe-uninitialized]
1943 | ((sorttype == 'S'
| ~~~~~~~~~~~~~~~~~
1944 | && strcmp(sortstring1, sortstring2) < 0)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1945 | || (sorttype != 'S' && sortval1 < sortval2)))) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dbops.c: In function ‘syncup_table’:
dbops.c:1835:23: note: ‘sortval2’ was declared here
1835 | int sortval1, sortval2;
| ^~~~~~~~
In function ‘cursor_comm’,
inlined from ‘syncup_table’ at dbops.c:2051:2:
dbops.c:1945:31: warning: ‘sortval1’ may be used uninitialized [-Wmaybe-uninitialized]
1943 | ((sorttype == 'S'
| ~~~~~~~~~~~~~~~~~
1944 | && strcmp(sortstring1, sortstring2) < 0)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1945 | || (sorttype != 'S' && sortval1 < sortval2)))) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dbops.c: In function ‘syncup_table’:
dbops.c:1835:13: note: ‘sortval1’ was declared here
1835 | int sortval1, sortval2;
| ^~~~~~~~
css.c: In function ‘qsaMatch’:
css.c:2387:28: warning: ‘rc’ may be used uninitialized [-Wmaybe-uninitialized]
2387 | if (rc)
| ^
css.c:2100:14: note: ‘rc’ was declared here
2100 | bool rc;
| ^~
In file included from /usr/include/quickjs/quickjs-libc.h:30,
from jseng-quick.c:18:
/usr/include/quickjs/quickjs.h: In function ‘JS_NewCFunctionMagic’:
/usr/include/quickjs/quickjs.h:969:34: warning: cast between incompatible function types from ‘JSValue (*)(JSContext *, JSValue, int, JSValue *, int)’ to ‘JSValue (*)(JSContext *, JSValue, int, JSValue *)’ [-Wcast-function-type]
969 | return JS_NewCFunction2(ctx, (JSCFunction *)func, name, length, cproto, magic);
| ^
cc -g -O2 -ffile-prefix-map=/tmp/edbrowse=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-unused -D_FILE_OFFSET_BITS=64 -DEDBROWSE_ON_LINUX -I/usr/include/x86_64-linux-gnu -g -ggdb -Wextra -Wdate-time -D_FORTIFY_SOURCE=2 -c -o ebrc.o ebrc.c
cc -g -O2 -ffile-prefix-map=/tmp/edbrowse=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-unused -D_FILE_OFFSET_BITS=64 -DEDBROWSE_ON_LINUX -I/usr/include/x86_64-linux-gnu -g -ggdb -Wextra -Wdate-time -D_FORTIFY_SOURCE=2 -c -o msg-strings.o msg-strings.c
jseng-quick.c: In function ‘setup_window_2’:
jseng-quick.c:3787:9: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
3787 | asprintf(&wpc, "Wp`Set@%s", cf->fileName);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jseng-quick.c: In function ‘set_basehref’:
jseng-quick.c:4448:17: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
4448 | asprintf(&wpc, "Wp`Set@%s", h);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc -g -O2 -ffile-prefix-map=/tmp/edbrowse=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-unused -D_FILE_OFFSET_BITS=64 -DEDBROWSE_ON_LINUX -I/usr/include/x86_64-linux-gnu -g -ggdb -Wextra -Wdate-time -D_FORTIFY_SOURCE=2 -c -o startwindow.o startwindow.c
jseng-quick.c: In function ‘embedNodeName’:
jseng-quick.c:2012:17: warning: ‘__builtin___strncpy_chk’ specified bound depends on the length of the source argument [-Wstringop-truncation]
2012 | strncpy(b, nodeName, length);
| ^
jseng-quick.c:2009:26: note: length computed here
2009 | length = strlen(nodeName);
| ^~~~~~~~~~~~~~~~
cc main.o buffers.o sendmail.o fetchmail.o html.o html-tags.o format.o stringfile.o ebrc.o msg-strings.o http.o isup.o css.o startwindow.o dbops.o dbodbc.o jseng-quick.o /usr/lib/x86_64-linux-gnu/quickjs/libquickjs.a -ldl -latomic -Wl,-z,relro -Wl,-z,now -lcurl -lodbc -lpcre2-8 -lreadline -lssl -lcrypto -lpthread -lm -lssl -lcrypto -o edbrowse
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-04-05 10:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-05 8:29 Karl Dahlke
2024-04-05 10:43 ` Sebastian Humenda [this message]
2024-04-05 11:14 ` Tyler Spivey
2024-04-05 11:52 ` Sebastian Humenda
2024-04-05 12:20 ` Tyler Spivey
[not found] ` <ZhABdF68z0u7NC7g@kraftkrust>
[not found] ` <3749fabd-aadf-95da-99da-04d34268a68a@pcdesk.net>
[not found] ` <ZhANkf4kZM2UkLka@kraftkrust>
2024-04-05 14:54 ` Tyler Spivey
2024-04-05 15:48 ` Tyler Spivey
2024-04-05 18:18 ` Sebastian Humenda
2024-04-05 18:37 ` Dominique Martinet
2024-04-05 18:47 ` Sebastian Humenda
2024-04-05 19:07 ` Dominique Martinet
2024-04-05 14:21 ` Karl Dahlke
2024-04-05 14:42 ` Sebastian Humenda
2024-04-05 15:10 ` Karl Dahlke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zg_Vvf27Bnlv3w2L@kraftkrust \
--to=shumenda@gmx.de \
--cc=edbrowse-dev@edbrowse.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).