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

Crash in strndup() #5621

Closed
DorpsGek opened this issue Jun 27, 2013 · 3 comments
Closed

Crash in strndup() #5621

DorpsGek opened this issue Jun 27, 2013 · 3 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

bentley opened the ticket and wrote:

The 1.3.1 build was failing on OpenBSD here:

./settings_gen -o table/settings.h -b /usr/ports/pobj/openttd-1.3.1/openttd-1.3.1/src/table/settings.h.preamble -a /usr/ports/pobj/openttd-1.3.1/openttd-1.3.1/src/table/settings.h.postamble /usr/ports/pobj/openttd-1.3.1/openttd-1.3.1/src/table/*.ini
Segmentation fault (core dumped)

The problem turns out to be an issue with strndup(). Replacing it with the native OpenBSD strndup() fixes the crash. So there is a bug in the openttd internal version somewhere.

This is 100% reproducible on OpenBSD with the "Junk" option set in /etc/malloc.conf: http://www.openbsd.org/cgi-bin/man.cgi?query=malloc

Backtrace:

(gdb) bt
# 0 0x000017f4a3c873c4 in strlen (
str=0x17f4add79c00 "; $Id: currency_settings.ini 24671 2012-11-08 10:04:00Z
frosch $\n;\n; This file is part of OpenTTD.\n; OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU Gener"...)
at /usr/src/lib/libc/string/strlen.c:43
# 1 0x000017f2a2802c53 in strndup (
s=0x17f4add79c00 "; $Id: currency_settings.ini 24671 2012-11-08 10:04:00Z frosch $\n;\n; This file is part of OpenTTD.\n; OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU Gener"..., len=640)
at /usr/ports/pobj/openttd-1.3.1/openttd-1.3.1/src/string.cpp:576
# 2 0x000017f2a2803de8 in IniLoadFile::LoadFromDisk (this=0x17f4b0595600,
filename=Variable "filename" is not available.
)
at /usr/ports/pobj/openttd-1.3.1/openttd-1.3.1/src/ini_load.cpp:265
# 3 0x000017f2a280428f in LoadIniFile (
filename=0x7f7ffffe3779 "/usr/ports/pobj/openttd-1.3.1/openttd-1.3.1/src/table/currency_settings.ini")
at /usr/ports/pobj/openttd-1.3.1/openttd-1.3.1/src/settingsgen/settingsgen.cpp:214
# 4 0x000017f2a2805c8e in main (argc=Variable "argc" is not available.
)
at /usr/ports/pobj/openttd-1.3.1/openttd-1.3.1/src/settingsgen/settingsgen.cpp:427

Reported version: 1.3.1
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5621
@DorpsGek
Copy link
Member Author

Alberth wrote:

Proposed patch, could you please test it?

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5621#comment12335

@DorpsGek
Copy link
Member Author

bentley wrote:

With fs5621.patch applied I can't reproduce the crash. Thanks.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5621#comment12354

@DorpsGek
Copy link
Member Author

Alberth closed the ticket.

Reason for closing: Implemented

Fixed in r25527, thanks for reporting and testing.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5621

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant