Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile.cmdline builds a broken binary that instantly segfaults #2534

Open
eli-schwartz opened this issue Mar 29, 2023 · 0 comments
Open

Makefile.cmdline builds a broken binary that instantly segfaults #2534

eli-schwartz opened this issue Mar 29, 2023 · 0 comments

Comments

@eli-schwartz
Copy link

Due to compiling with -std=c99 it has 13 warnings. Removing the flag entirely and letting GCC use whatever std it pleases, results in a warning-free build and no segfaults.

The warnings are relevant:

examples/cmdline/duk_cmdline.c: In function ‘linenoise_hints’:
examples/cmdline/duk_cmdline.c:446:23: warning: implicit declaration of function ‘strdup’; did you mean ‘strcmp’? [-Wimplicit-function-declaration]
  446 |                 res = strdup(duk_safe_to_string(ctx, -1));
      |                       ^~~~~~
      |                       strcmp
examples/cmdline/duk_cmdline.c:446:21: warning: assignment to ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  446 |                 res = strdup(duk_safe_to_string(ctx, -1));
      |                     ^
examples/cmdline/duk_cmdline.c:460:29: warning: assignment to ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  460 |                         res = strdup(tmp);
      |                             ^
linenoise/linenoise.c: In function ‘isUnsupportedTerm’:
linenoise/linenoise.c:215:14: warning: implicit declaration of function ‘strcasecmp’; did you mean ‘strncmp’? [-Wimplicit-function-declaration]
  215 |         if (!strcasecmp(term,unsupported_term[j])) return 1;
      |              ^~~~~~~~~~
      |              strncmp
linenoise/linenoise.c: In function ‘refreshMultiLine’:
linenoise/linenoise.c:622:31: warning: ISO C99 requires at least one argument for the "..." in a variadic macro
  622 |             lndebug("clear+up");
      |                               ^
linenoise/linenoise.c:630:24: warning: ISO C99 requires at least one argument for the "..." in a variadic macro
  630 |         lndebug("clear");
      |                        ^
linenoise/linenoise.c:654:32: warning: ISO C99 requires at least one argument for the "..." in a variadic macro
  654 |             lndebug("<newline>");
      |                                ^
linenoise/linenoise.c:683:17: warning: ISO C99 requires at least one argument for the "..." in a variadic macro
  683 |     lndebug("\n");
      |                 ^
linenoise/linenoise.c: In function ‘linenoiseEditHistoryNext’:
linenoise/linenoise.c:792:55: warning: implicit declaration of function ‘strdup’; did you mean ‘strcmp’? [-Wimplicit-function-declaration]
  792 |         history[history_len - 1 - l->history_index] = strdup(l->buf);
      |                                                       ^~~~~~
      |                                                       strcmp
linenoise/linenoise.c:792:53: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  792 |         history[history_len - 1 - l->history_index] = strdup(l->buf);
      |                                                     ^
linenoise/linenoise.c: In function ‘linenoiseEditFeed’:
linenoise/linenoise.c:963:16: warning: returning ‘int’ from a function with return type ‘char *’ makes pointer from integer without a cast [-Wint-conversion]
  963 |         return strdup(l->buf);
      |                ^~~~~~~~~~~~~~
linenoise/linenoise.c: In function ‘linenoise’:
linenoise/linenoise.c:1206:16: warning: returning ‘int’ from a function with return type ‘char *’ makes pointer from integer without a cast [-Wint-conversion]
 1206 |         return strdup(buf);
      |                ^~~~~~~~~~~
linenoise/linenoise.c: In function ‘linenoiseHistoryAdd’:
linenoise/linenoise.c:1266:14: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1266 |     linecopy = strdup(line);
      |              ^

P.S. would you be interested in a build system that's a bit more... flexible... than the current difficult-to-use one? With the amount of time I spend hand-editing the Makefiles, it feels like maybe I should just copy-paste the failing command line and run gcc myself. Even the Makefile explicitly says:

The source distributable has more platform neutral example Makefiles for end user projects, though an end user should really just use their own build system.

Seems like it could be advantageous to be consistent with support. I'd suggest https://sr.ht/~lattis/muon/, a very fast, lightweight build system with a lot of power.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant