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

Introduce checked undefined behavior (aka development mode) #14

Closed
densh opened this issue Feb 25, 2016 · 2 comments
Closed

Introduce checked undefined behavior (aka development mode) #14

densh opened this issue Feb 25, 2016 · 2 comments

Comments

@densh
Copy link
Member

densh commented Feb 25, 2016

Scala native is going to have a relaxed safety model with checked undefined behaviour similar to Scala.js. In development mode all situations that can cause undefined behaviour throw UndefinedBehaviourError.

Guarded situations:

  • null pointer dereference
  • invalid class casts
  • arithmetic corner cases
  • stack overflows
  • ...

On the IR-level such checks are going to be represented through special guard $condition op that throws the scala.scalantive.runtime.UndefinedBehaviourError if condition is not true under development mode and does nothing in production mode.

@densh densh modified the milestones: M1, M2 Feb 25, 2016
@densh densh modified the milestones: M3, M2 Mar 4, 2016
@densh densh changed the title Introduce guards Introduce checked undefined behaviour Mar 23, 2016
@densh densh changed the title Introduce checked undefined behaviour Introduce checked undefined behavior Mar 23, 2016
@densh densh mentioned this issue Apr 25, 2016
11 tasks
@densh densh modified the milestones: M3, M2 May 2, 2016
@densh
Copy link
Member Author

densh commented May 4, 2016

We also want to lower guards to calls to llvm.assume in unchecked mode.

@densh densh modified the milestones: M4, M3 Jun 6, 2016
@densh densh mentioned this issue Oct 19, 2016
@densh densh changed the title Introduce checked undefined behavior Introduce checked undefined behavior (aka development mode) Oct 25, 2016
@densh densh modified the milestones: Backlog, 0.1 Dec 1, 2016
@densh densh added feature and removed critical labels Jan 3, 2017
@densh densh modified the milestones: Backlog, Wontfix Jan 9, 2018
@densh
Copy link
Member Author

densh commented Jan 9, 2018

Superseded by #1140

@densh densh closed this as completed Jan 9, 2018
@densh densh modified the milestones: Wontfix , Duplicate Jan 9, 2018
avdv added a commit to avdv/scala-native that referenced this issue Apr 29, 2020
```
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7de4451 in __strlen_avx2 () from /nix/store/6m2k8kx8h216jlx9dg3lp4m90bz05yck-glibc-2.30/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7de4451 in __strlen_avx2 () from /nix/store/6m2k8kx8h216jlx9dg3lp4m90bz05yck-glibc-2.30/lib/libc.so.6
#1  0x00000000005805b2 in _SM33scala.scalanative.unsafe.package$D11fromCStringL28scala.scalanative.unsafe.PtrL24java.nio.charset.CharsetL16java.lang.StringE ()
scala-native#2  0x0000000000658399 in _SM47scala.scalanative.nio.fs.UnixFileSystemProviderD10getUserDirL16java.lang.StringE ()
scala-native#3  0x00000000006583e6 in _SM47scala.scalanative.nio.fs.UnixFileSystemProviderD13fs$lzycomputeL39scala.scalanative.nio.fs.UnixFileSystemE ()
scala-native#4  0x000000000065856a in _SM47scala.scalanative.nio.fs.UnixFileSystemProviderD13getFileSystemL12java.net.URIL24java.nio.file.FileSystemE ()
scala-native#5  0x0000000000755482 in _SM26java.nio.file.FileSystems$D13fs$lzycomputeL24java.nio.file.FileSystemE ()
scala-native#6  0x0000000000754696 in _SM26java.nio.file.FileSystems$D10getDefaultL24java.nio.file.FileSystemE ()
scala-native#7  0x0000000000700809 in _SM20java.nio.file.Paths$D13fs$lzycomputeL24java.nio.file.FileSystemE ()
scala-native#8  0x00000000007008c0 in _SM20java.nio.file.Paths$D3getL16java.lang.StringLAL16java.lang.String_L18java.nio.file.PathE ()
scala-native#9  0x00000000006375fa in _SM34de.bley.scalals.Core$$anonfun$ls$1D5applyL29scala.scalanative.unsafe.ZoneuE ()
scala-native#10 0x00000000006374f8 in _SM34de.bley.scalals.Core$$anonfun$ls$1D5applyL16java.lang.ObjectL16java.lang.ObjectE ()
scala-native#11 0x0000000000680a2b in _SM30scala.scalanative.unsafe.Zone$D5applyL15scala.Function1L16java.lang.ObjectE ()
scala-native#12 0x0000000000670226 in _SM21de.bley.scalals.Core$D2lsL22de.bley.scalals.ConfiguE ()
scala-native#13 0x00000000006d6170 in _SM36de.bley.scalals.Main$$anonfun$main$1D5applyL22de.bley.scalals.ConfiguE ()
scala-native#14 0x00000000006d6116 in _SM36de.bley.scalals.Main$$anonfun$main$1D5applyL16java.lang.ObjectL16java.lang.ObjectE ()
scala-native#15 0x000000000065dfb7 in _SM12scala.OptionD7foreachL15scala.Function1uE ()
scala-native#16 0x0000000000700e47 in _SM21de.bley.scalals.Main$D4mainLAL16java.lang.String_uE ()
scala-native#17 0x0000000000680516 in main ()
```

Note: starting a JVM in an unlinked directory, results in an Error:

```
Error occurred during initialization of VM
java.lang.Error: Properties init: Could not determine current working directory.
  at jdk.internal.util.SystemProps$Raw.platformProperties(java.base/Native Method)
  at jdk.internal.util.SystemProps$Raw.<init>(java.base/SystemProps.java:241)
  at jdk.internal.util.SystemProps.initProperties(java.base/SystemProps.java:54)
  at java.lang.System.initPhase1(java.base/System.java:1997)
```
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Wed Apr 29 22:12:30 2020 +0200
#
# HEAD detached from 6cb2caa
# Changes to be committed:
#	modified:   javalib/src/main/scala/scala/scalanative/nio/fs/UnixFileSystemProvider.scala
#
# Untracked files:
#	javalib/src/main/scala/scala/scalanative/nio/fs/UnixFileSystemProvider.scala_segfault
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant